-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring-data throw JsonMappingException when using PageImpl #41292
Comments
/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, 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:
|
thanks for investigation @aureamunoz I'll let @jedla97 look into it when he is back next week |
Can we close this one? @jedla97 @michalvavrik ? |
hey @jedla97 please check or ping me directly if you don't have time and I'll. thanks |
I'll look at this later this week. |
The original test was based on serialization, which is no longer possible out of bot. In quarkusio/quarkus#41292 was suggested use this modification to make the original code work. Now we checking if retunred json, pageable item contains specific values. For more info see quarkusio/quarkus#41292 (comment)
@aureamunoz thanks for instruction. It worked fine in jvm. I just needed to refactor the test for it which was checking the serialization (for native specificaly). As now the serialization is not out-of-box the whole behavioral is different. I have just one question. Is the missing elements
This is just part of the response. In native the same part looks like this:
|
…attributes. Related to quarkusio#41292
Oh! good catch! the paged/unpaged attributes should be present. I've just raised a PR for fixing it. |
…attributes. Related to quarkusio#41292
…attributes. Related to quarkusio#41292
…attributes. Related to quarkusio#41292 (cherry picked from commit 57c250d)
I see this is already closed. But can confirm that the fix for native is working, so I'm not against closing this issue. |
The original test was based on serialization, which is no longer possible out of bot. In quarkusio/quarkus#41292 was suggested use this modification to make the original code work. Now we checking if retunred json, pageable item contains specific values. For more info see quarkusio/quarkus#41292 (comment)
The original test was based on serialization, which is no longer possible out of box. In quarkusio/quarkus#41292 was suggested use this modification to make the original code work. Now we checking if returned json, pageable item contains specific values. For more info see quarkusio/quarkus#41292 (comment)
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 #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 [email protected]: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
The text was updated successfully, but these errors were encountered: