Skip to content

JAXB message converters ignore Content-Type charsetΒ #34745

Closed

Description

@pax95

Hi

I have created a Stackoverflow with the details here https://stackoverflow.com/questions/79568225/restclient-message-converters-unable-to-parse-iso-8859-1-response-from-remote-se

It seems that setting the DefaultCharset on RestClient messageconverters doesn't have any effeft when marshalling a iso-8859-1 response.

Currently the workaround is to take the response as a string and then manually unmarshall to jaxb objects

var xml = woRestClient.get()
            .uri("myuri")
            .retrieve()
            .body(String.class);
        var programs = JaxbUtils.unmarshall(xml, Programs.class);

There is a simelar question here https://stackoverflow.com/questions/77663426/restclient-how-to-correctly-unmarshall-text-xml-response

Activity

  1. changed the title [-]RestClient message converters unable to parse ISO-8859-1 response from remote server[/-] [+]RestClient message converters unable to parse ISO-8859-1 response[/+] on Apr 12, 2025
  2. added
    in: webIssues in web modules (web, webmvc, webflux, websocket)
    on Apr 15, 2025
  3. pax95 commented on Apr 16, 2025

    @pax95
    Author

    I currently use the workaround described in stacoverflow, and will leave the issue open to see if there is any way to change the messageconverter behaviour to accept a iso bytestream, and convert it, if the defaultCharset has been set on it.
    If not then the workaround is acceptable.

  4. self-assigned this
    on May 19, 2025
  5. bclozel commented on May 19, 2025

    @bclozel
    Member

    I think this is quite similar to #28599 and I think this is doable here by setting the encoding property on the InputSource, if it is provided in the Content-Type header value.

  6. added and removed on May 19, 2025
  7. added this to the 6.2.8 milestone on May 19, 2025
  8. changed the title [-]RestClient message converters unable to parse ISO-8859-1 response[/-] [+]JAXB message converters ignore Content-Type charset[/+] on May 19, 2025
  9. added a commit that references this issue on May 19, 2025
    2af0323
  10. pax95 commented on May 19, 2025

    @pax95
    Author

    Great support. Thanks @bclozel

  11. added a commit that references this issue on Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions