Skip to content

Regression issue with response encoding between Spring Boot 2.1.x and 2.2.x #24477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dawiking opened this issue Feb 4, 2020 · 5 comments
Closed
Assignees
Labels
for: external-project Needs a fix in external project in: web Issues in web modules (web, webmvc, webflux, websocket)

Comments

@dawiking
Copy link

dawiking commented Feb 4, 2020

Affects: Spring Boot 2.2.x


We have identified a regression issue while upgrading from Spring Boot 2.1.11 to Spring Boot 2.2.4.
In Spring 5.2.x MediaType.APPLICATION_JSON_UTF8 has been deprecated. If we replace produces = APPLICATION_JSON_UTF8_VALUE on endpoints with produces = APPLICATION_JSON_VALUEour contract tests fails with error

java.lang.IllegalStateException: Parsed JSON [{"name":"David S��der"}] doesn't match the JSON path [$[?(@.['name'] == 'David Söder')]]

No change has been made to the contract tests in the upgrade process.
This looks very much like #24123 but since we're already using Spring 5.2.3 that is already in place.

I have created a very basic test project which showcases the issue. You can find it here.

Are we missing some configuration? Is there another way to solve this in 2.2.x?

Please let me know if more information is needed.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 4, 2020
@rstoyanchev
Copy link
Contributor

Using the attached project, I get no failures, all tests pass and the error is without the stack trace. Please, provide more details.

@rstoyanchev rstoyanchev self-assigned this Feb 4, 2020
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) status: waiting-for-feedback We need additional information before we can continue labels Feb 4, 2020
@dawiking
Copy link
Author

dawiking commented Feb 4, 2020

For some reason my gradle instance is run with -Dfile.encoding=US-ASCII which causes the issue. If I change the file.encoding system property the project tests complete successfully.

Thanks for looking into it.

@dawiking dawiking closed this as completed Feb 4, 2020
@dawiking
Copy link
Author

dawiking commented Feb 4, 2020

But... something has changed in Spring which causes the test to fail now. Why does it work for a boot 2.1.x project with file.encoding=US-ASCII but not 2.2.x? I'm not saying it is correct to have US-ASCII as encoding though so we should probably fix that.

@dawiking dawiking reopened this Feb 4, 2020
@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 4, 2020
@rstoyanchev
Copy link
Contributor

The reasons are explained in #22788. Previously the response had a charset that forced the interpretation of the response. To comply with the RFC, the response now does not have a charset and clients must interpret it as UTF-8 by default. I don't know what in your test stack is responsible for decoding the response. That's why I was looking for a failing test. I still can't get it to fail.

@rstoyanchev rstoyanchev added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Feb 4, 2020
@dawiking
Copy link
Author

dawiking commented Feb 5, 2020

The problem was in rest-assured, spring-mock-mvc module.

@dawiking dawiking closed this as completed Feb 5, 2020
@rstoyanchev rstoyanchev added for: external-project Needs a fix in external project and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a fix in external project in: web Issues in web modules (web, webmvc, webflux, websocket)
Projects
None yet
Development

No branches or pull requests

3 participants