Skip to content

[BUG] [java][native] Encoding failure due to last change of empty response handling #20556

@markusschaefer

Description

@markusschaefer

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

The change in api.mustache to use a new String instead of passing the InputStream direct to the ObjectMapper causes an encoding problem. ObjectMapper always uses UTF-8 for encoding. The Constructor String(byte[] bytes) uses the default Characterset of the running virtual machine.

openapi-generator version

7.11.0

OpenAPI declaration file content or url

String responseBody = new String(localVarResponse.body().readAllBytes());

Steps to reproduce

use a native client in a java app that is running with a default encoding, that is not UTF-8

Related issues/PRs

#20334

Suggest a fix

Revert the usage of String(byte[] bytes) or use public String(byte[] bytes, Charset charset)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions