Skip to content
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

MappingAwarePageableArgumentResolver accidentally drops default Pageable returned from delegate PageableHandlerMethodArgumentResolver [DATAREST-906] #1274

Closed
spring-projects-issues opened this issue Sep 21, 2016 · 9 comments
Assignees
Labels
type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 21, 2016

Michael Igler opened DATAREST-906 and commented

After upgrading to spring-boot 1.4.1 which includes Hopper-SR3 I get a NPE in the following code section when Pageable is not set explicitly:

public Page<Translation> findTranslationsBy(String isoCode, Pageable pageable) {
log.info("" + pageable.getPageSize());
....
}

Setting HOPPER-SR2 in pom.xml fixes the problem as a default page-size is taken into account.


Affects: 2.4.5 (Gosling SR5), 2.5.3 (Hopper SR3)

Issue Links:

  • DATAREST-909 Revert Jackson-aware Sort and Pageable translation in Hopper and Gosling release trains

Referenced from: pull request #231

Backported to: 2.5.4 (Hopper SR4), 2.4.6 (Gosling SR6)

2 votes, 7 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 21, 2016

Oliver Drotbohm commented

I am assuming you're talking about a controller method here? Who's resolving the Pageable in the first place? What does the request look like? What does your setup for PageableHandlerMethodArgumentResolver} look like?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 21, 2016

Michael Igler commented

Yes, a controller method. The request is "http://localhost:8080/api/languages/9dbf1bf3-3b52-4b88-a356-2f9b6edece04/translations". I have no manual setup for "PageableHandlerMethodArgumentResolver".

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 22, 2016

Michael Igler commented

If I replace @RepositoryRestController through @Controller, then Pageable is initialized with default values (if not set through url-parameters)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 22, 2016

Oliver Drotbohm commented

Looks like the newly introduced MappingAwarePageableArgumentResolver (to fix DATAREST-883) accidentally drops Pageable instances that don't have no Sort instance attached to it, which unfortunately is the case for the default one being returned from PageableHandlerMethodArgumentResolver

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 23, 2016

Oliver Trosien commented

.. got bitten by that, too. Is there a known work-around?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 23, 2016

Oliver Drotbohm commented

So far, it looks like the only way is manually checking the instance for null and manually assigning the default then

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 23, 2016

Mark Paluch commented

Another workaround is using DefaultedPageable that contains the resolved Pageable (Our repository controllers use primarily DefaultedPageable)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 23, 2016

Oliver Drotbohm commented

Fix is in place and snapshots should be available soon. Would be cool if you could give them a spin

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 5, 2016

Michael Igler commented

DefaultedPageable and Hopper-SR4 both fix the problem. Thanx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug
Projects
None yet
Development

No branches or pull requests

2 participants