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.
Comment From: rstoyanchev
Using the attached project, I get no failures, all tests pass and the error is without the stack trace. Please, provide more details.
Comment From: dawiking
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.
Comment From: dawiking
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.
Comment From: rstoyanchev
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.
Comment From: dawiking
The problem was in rest-assured, spring-mock-mvc module.