Skip to content

Added a exception handling for when was specified the invalid value in the pagination parameter. #48

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

Closed
wants to merge 1 commit into from

Conversation

kazuki43zoo
Copy link

[example of invalid value]

  • page=-1 (negative numeric)
  • size=a (not numeric)
  • sort= (not specified)
  • sort=,DESC (not specified property of sort target)
  • etc ...

Current implementation of the PageableHandlerMethodArgumentResolver is occurred IllegalArgumentException, and http response status is returned 500(Innternal Server Error) on the default setting of SpringMVC.
I think a best that http response status is returned 400(Bad Request).

Easy a way for resolve this problem is that catch a IllegalArgumentException in PageableHandlerMethodArgumentResolver, and throw a ServletRequestBindingException.
ServletRequestBindingException is handled by the DefaultHandlerExceptionResolver, and http response status is returned 400(Bad Request).

What Do you think?
If you have a same thinking, Please pushed to a master branch.

ServletRequestBindingException an IllegalArgumentException.
@kazuki43zoo
Copy link
Author

I think that may be another solution.

@odrotbohm
Copy link
Member

Would you mind creating a ticket in JIRA for this?

@kazuki43zoo
Copy link
Author

created a ticket in JIRA.
see https://jira.springsource.org/browse/DATACMNS-408.

odrotbohm added a commit that referenced this pull request Dec 5, 2013
…fully.

The PageableHandlerMethodArgumentResolver and SortHandlerMethodArgumentResolver now transparently ignore invalid values provided for page number, size and sort. We fall back to ignore the invalid values (for sort) and fall back to the defaults where appropriate (page number and size).

Used and adapted test cases from pull request #48.
odrotbohm added a commit that referenced this pull request Dec 5, 2013
…fully.

The PageableHandlerMethodArgumentResolver and SortHandlerMethodArgumentResolver now transparently ignore invalid values provided for page number, size and sort. We fall back to ignore the invalid values (for sort) and fall back to the defaults where appropriate (page number and size).

Used and adapted test cases from pull request #48.
@odrotbohm odrotbohm closed this Dec 10, 2013
@kazuki43zoo
Copy link
Author

thanks that this issue resolved.

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

Successfully merging this pull request may close these issues.

2 participants