spring-cloud / spring-cloud-release

Spring Cloud Release Train - dependency management across a wide range of Spring Cloud projects.
http://projects.spring.io/spring-cloud
Apache License 2.0
874 stars 179 forks source link

Page desrialization fails whe upgrading to 2023.0.2 #290

Closed banyan-god closed 2 months ago

banyan-god commented 2 months ago

Describe the bug Using spring boot 3.2.7 with spring cloud '2023.0.2' .

Appears this property was disabled on previous versions DeserializationFeature.FAIL_ON_TRAILING_TOKENS but it is now enabled on this '2023.0.2'

Jackson is unable to deserialize Page Object

Trailing token (of type FIELD_NAME) found after value (bound as `com.fasterxml.jackson.databind.JsonNode`): not allowed as per `DeserializationFeature.FAIL_ON_TRAILING_TOKENS`
 at [Source: (String)"{"content":["HE"],"pageable":{"pageNumber":0,"pageSize":1,"sort":[],"offset":0,"paged":true,"unpaged":false},"last":true,"totalElements":1,"totalPages":1,"first":true,"size":1,"number":0,"sort":[],"numberOfElements":1,"empty":false}"; line: 1, column: 69] (through reference chain: org.springframework.cloud.openfeign.support.PageJacksonModule$SimplePageImpl["pageable"]->org.springframework.cloud.openfeign.support.PageJacksonModule$SimplePageable["sort"])
com.fasterxml.jackson.databind.exc.MismatchedInputException: Trailing token (of type FIELD_NAME) found after value (bound as `com.fasterxml.jackson.databind.JsonNode`): not allowed as per `DeserializationFeature.FAIL_ON_TRAILING_TOKENS`
 at [Source: (String)"{"content":["HE"],"pageable":{"pageNumber":0,"pageSize":1,"sort":[],"offset":0,"paged":true,"unpaged":false},"last":true,"totalElements":1,"totalPages":1,"first":true,"size":1,"number":0,"sort":[],"numberOfElements":1,"empty":false}"; line: 1, column: 69] (through reference chain: org.springframework.cloud.openfeign.support.PageJacksonModule$SimplePageImpl["pageable"]->org.springframework.cloud.openfeign.support.PageJacksonModule$SimplePageable["sort"])
    at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
    at com.fasterxml.jackson.databind.DeserializationContext.reportTrailingTokens(DeserializationContext.java:1825)

Sample

@SpringBootTest
class IPlanRepoTest {

    @Autowired
    ObjectMapper objectMapper;

    @Test
    void pagetest() throws JsonProcessingException {

        Page<String> page = new PageImpl<String>(Collections.singletonList("HE"), Pageable.ofSize(1),1);
        String s = objectMapper.writeValueAsString(page);
        boolean isEnabled = objectMapper.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
        System.out.println(isEnabled);
        System.out.println(s);
        Page<String> page2 = objectMapper.readValue(s, new TypeReference<Page<String>>() {});

    }
}
spencergibb commented 2 months ago

None of this looks like it involves spring cloud

banyan-god commented 2 months ago

Well I am puzzled as well but upgrading to spring cloud '2023.0.2' is the one causing it

OlgaMaciaszek commented 2 months ago

@banyan-god please provide a minimal, complete, verifiable example that reproduces the issue.

banyan-god commented 2 months ago

Found a way to address it https://docs.spring.io/spring-data/commons/reference/repositories/core-extensions.html#core.web.page.config