Description
Affects: spring 6.1.0-RC2 with spring boot 3.2.0-RC2 and JDK21
Description
I've attached a sample Spring Boot application with a single endpoint that deserializes a date from the request data. The deserialization happens in the following lines of DateDeserializerConfig
module.addDeserializer(LocalDateTime.class, new JsonDeserializer<>() {
@Override
public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException {
// the following line returns null when invoked with a RestClient
String dateTimeWithZone = jsonParser.getValueAsString();
logger.info("Converting {} to LocalDateTime", dateTimeWithZone);
return ZonedDateTime.parse(dateTimeWithZone).toLocalDateTime();
}
});
Steps to Reproduce
The application contains 2 integration tests, one of which invokes the endpoint with a RestClient
and the other uses WebTestClient
. The same request data, headers, etc. are used in both cases.
If the tests in DemoApplicationTests
are run, testEndpointWithWebClient
passes, but testEndpointWithRestClient
fails. The failure is caused by jsonParser.getValueAsString()
returning null when the latter test runs.
If the date deserialization logic is removed, both tests pass.
demo.zip