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

SortHandlerMethodArgumentResolver fails to fall back to default if empty parameter is given [DATACMNS-753] #1214

spring-projects-issues opened this issue Aug 14, 2015 · 1 comment
in: core type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Aug 14, 2015

Ruben Dijkstra opened DATACMNS-753 and commented

When the sort parameter is empty (?sort=) it becomes a non-null, empty String.
The current logic does not handle this case properly when the handler method is annotated with SortDefault or SortDefaults.

I have provided the PR with the test case.
(If you want a specific target branch, then let me know. If you want to backport it to different branches then do so)

Proposed fix:

String[] directionParameter = webRequest.getParameterValues(getSortParameter(parameter));

Sort sort = null;
if (directionParameter != null && directionParameter.length != 0) {
	sort = parseParameterIntoSort(directionParameter, propertyDelimiter);
// if sort ends up empty
if (sort == null) {
	return getDefaultFromAnnotationOrFallback(parameter);
} else {
	return sort;

Issue Links:

  • DATACMNS-408 Guard against invalid values when resolving pagination and sorting parameters from web requests

Referenced from: pull request #138

Backported to: 1.11.1 (Gosling SR1), 1.10.3 (Fowler SR3)

Copy link

@spring-projects-issues spring-projects-issues commented Sep 9, 2015

Oliver Drotbohm commented

That's merged and fixed in master as well as the bugfix branches for Gosling and Hopper

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

No branches or pull requests

2 participants