Describe the bug I use new stable page representation format enabled with @EnableSpringDataWebSupport(pageSerializationMode = VIA_DTO). When I try to download paged response from controller via feign client, page metadata isn't correctly parsed. Total elements number always equals number of elements in current page content (page content is parsed correctly). It seems that PageJacksonModule expects page metadata in the old format.

I'm using Spring Cloud v2024.0.0.

Sample Sample project to reproduce this problem lives at https://github.com/exempla/sb3_stable_page_feign_deserialization_problem. Run mvn test to see the error.

Comment From: OlgaMaciaszek

Thanks for reporting the issue, @fenuks. This would be a new enhancement. In general, we don't add enhancements to this project anymore, as it's in maintenance mode now (we suggest migrating over to Spring Interface Clients), but I think we may add support for this. However, I'm not sure when we'll be able to put this in the backlog, as maintenance-only projects have low priority. Feel free to submit a PR if you'd like it to be included faster.

Comment From: fenuks

I could try to do that. It would be great if both page representations were supported at the same time, but I'm not sure if it is possible with current implementation based on Jackson module?

Comment From: OlgaMaciaszek

@fenuks we need to support both. Could be using an opt-in flag for the new mode as the old mode hasn't been deprecated and is still in use. Then, in the next major release, we could swap the defaults.

Comment From: fenuks

Yes, I would like to support them both, but I wonder if we could support both without any flag.

Currently JacksonModule is being used and Jackson calls this constructor:

        SimplePageImpl(@JsonProperty("content") List<T> content,
@JsonProperty("pageable") Pageable pageable,
                @JsonProperty("number") @JsonAlias("pageNumber") int number,
                @JsonProperty("size") @JsonAlias("pageSize") int size,
                @JsonProperty("totalElements") @JsonAlias({ "total-elements",
"total_elements", "totalelements",
                        "TotalElements", "total" }) long totalElements,
                @JsonProperty("sort") Sort sort)

Fixing it to new representation is easy, one needs to rewrite it to

        SimplePageImpl(@JsonProperty("content") List<T> content,
                @JsonProperty("page") PagedModel.PageMetadata page),

Sorry for lack of clarity, what I was asking in previous post, is if we can support both page representations at the same time using JacksonModule or this mechanism is too limited to handle this? I know this could be done with new feign Decoder.

Say, I have feign client that consumes controller that for methods written pre-SB 3.0 still uses old page format for compatibility reasons, but all new methods use new stable format.