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

Consistency in Parameter Value conversion #338

Closed
munendrasn opened this issue Jan 3, 2017 · 3 comments
Closed

Consistency in Parameter Value conversion #338

munendrasn opened this issue Jan 3, 2017 · 3 comments

Comments

@munendrasn
Copy link
Collaborator

For following url, example.com?q=&format=json

while converting q to different data types, response would be as follows

routeContext.getParameter("q").toInt() # gives 0(default value)
routeContext.getParameter("q").toString() # gives empty string
routeContext.getParameter("q").toList() # gives a list containing empty string

Shouldn't toList() return empty list??

This is because in toList method in ParameterValue.java, only null check is done.
It would be better to check for this condition also

if (isNull() || (values.length==1 && StringUtils.isNullorEmpty(values[0])))

This would return defaultValue (in this case, empty list). or is there a reason for present approach??
If my approach looks good, I will raise a PR for this one

@decebals
Copy link
Member

decebals commented Jan 4, 2017

Probably the correct behavior for your example (example.com?q=&format=json and routeContext.getParameter("q").toList()) is to return an empty list.

@munendrasn
Copy link
Collaborator Author

@decebals I do agree on that.
Even for toSet() it should return empty set.
Should I create PR for this one??

@decebals
Copy link
Member

decebals commented Jan 4, 2017

@munendrasn Please

decebals added a commit that referenced this issue Jan 4, 2017
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

No branches or pull requests

2 participants