Open jedla97 opened 4 months ago
/cc @geoand (spring)
cc aureamunoz as this is probably related to bump of the spring
Let's make sure we add some tests when we fix this. Thanks!
hey @jedla97 @aureamunoz, I am looking at the Quarkus QE test coverage for Spring and wondering about this one. Is this fixed, to do, or not a bug?
I try the reproducer and it's still failing, so it's not fixed/explained.
From my POV it's a bug, as this worked fine before. Maybe it's only error in implementation as something changes but I don't see anything in our migration guide.
Oops, I completely missed this one, I need to take a look closer. I will work on it next week
Thanks @jedla97 @aureamunoz
I investigated this issue, and it turns out the problem isn't on our side. Starting from Spring Boot 3.2, Unpaged instances are no longer Jackson-serializable by default. As mentioned in the linked issue, the problem isn't that Unpaged instances now are non-serializable. Previously, Unpaged
was represented as an Enum
, which always serialized to a String. However, this has changed—Unpaged
is now represented by an object, which alters the serialization behavior.
To resolve this, you should use the PageImpl constructor that takes a List of content, pagination details, and the total item count, rather than just passing the collection. In your reproducer code, passing only the collection results in the creation of an Unpaged object making it non-serializable.
To fix the issue, I recommend updating the BookStore#findPaged method as follows:
public Page<Book> findPaged(Pageable pageable) {
List<Book> list = this.findAll().list();
return new PageImpl<>(list,pageable,list.size());
}
cc @jedla97 @michalvavrik
thanks for investigation @aureamunoz I'll let @jedla97 look into it when he is back next week
Describe the bug
Returnning
PageImpl
to the endpoint causing throwcom.fasterxml.jackson.databind.JsonMappingException: (was java.lang.UnsupportedOperationException) (through reference chain: org.springframework.data.domain.PageImpl["pageable"]->org.springframework.data.domain.Unpaged["pageSize"])
This is probably caused by bump of spring in https://github.com/quarkusio/quarkus/pull/40344.
The attached reproduces working with
3.11.2
and failing with999-SNAPSHOT
Also using
quarkus-rest-jackson
the endpoint return 500 and usingquarkus-resteasy-jackson
return 400 but that's probably difference in implamentation of these extensions.Using
quarkus-resteasy-jackson
returningNot able to deserialize data provided.
and error is shown only in log.Expected behavior
Expecting to get result from endpoint based on passed parameters.
For example on http://localhost:8080/book/paged?size=1&page=0 return should be like this
Actual behavior
Error:
How to Reproduce?
git clone -b spring-paged-rest git@github.com:jedla97/quarkus-reproducers.git
cd quarkus-reproducers
mvn clean verify
mvn clean verify -Dquarkus.platform.version=3.11.2
In addition you can run it in dev mode and access it on http://localhost:8080/book/paged?size=1&page=0
Also you can try resteasy by change branche to
spring-paged-resteasy
Output of
uname -a
orver
Fedora 40, Ubuntu 22 (Github runner)
Output of
java -version
OpenJDK 21
Quarkus version or git rev
main
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.3
Additional information
No response