Closed
Description
Affects: org.springframework:spring-web:5.1.15.RELEASE
XML webservices seem to be limited to unicode encodings. Using jackson-dataformat-xml 2.9.8 for a webservice which produces "text/xml;charset=ISO-8859-1" outputs utf-8.
The problem might be located in AbstractJackson2HttpMessageConverter:
...
protected void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
MediaType contentType = outputMessage.getHeaders().getContentType();
JsonEncoding encoding = getJsonEncoding(contentType);
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(outputMessage.getBody(), encoding);
...
JsonEncoding only provides unicode. A workaround would be to override the whole method but it is quite lenghty.
I made a very small reproducer: https://github.com/saimonsez/spring-jackson-xml-encoding-problem