Skip to content

(JAX-RS) Encoding issue when ConverterProvider converts entityStream to String #603

Closed
@jgoubert

Description

@jgoubert

The ConverterProvider.readFrom() method creates a new InputRepresentation around the entityStream, but ignores the character set of the entity. When converting to a String, the DefaultConverter calls getText() on this InputRepresentation, which delegates to BioUtils.toString(getStream(), getCharacterSet()). Since getCharacterSet() returns null, the default (i.e. system) charset is used, which could be different from the actual charset.
I think the character set of the entity should be taken into account, as is the case in e.g. StringProvider, where "getCurrentRequestEntityCharacterSet()" is used.

Apart from this, what looks like a bug to me, I find it a little strange that the ConverterProvider is used instead of the StringProvider. Actually, the JaxRsProviders.getBestReader() method doesn't really look for the best reader, but takes the first one it encounters that is suitable. Since it finds ConverterProvider before StringProvider, and the former says it can convert representations of all mediaTypes to String, it will always be chosen instead of StringProvider, rendering the latter useless.
Or perhaps I'm missing something here ? I must admit that I'm not very familiar with the ConverterService business.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions