[
https://issues.apache.org/jira/browse/CXF-7307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15950577#comment-15950577
]
Sergey Beryozkin commented on CXF-7307:
---------------------------------------
404 is correct in general when the query parameter conversion fails (this is
spec compliant).
What I'm not 100% sure is what to do with an empty value.
A null Integer indicates that no parameter has been provided at all, while in
this case it has actually been provided, so 'null' will not represent that
fact. Therefore if you need to support empty values then use String. Can you
please check how Jersey reacts in this case ?
Thanks, Sergey
> empty query string injects into number type will lead 404 error
> ----------------------------------------------------------------
>
> Key: CXF-7307
> URL: https://issues.apache.org/jira/browse/CXF-7307
> Project: CXF
> Issue Type: Bug
> Components: Core, JAX-RS
> Affects Versions: 3.1.7, 3.0.12
> Environment: xos jdk 1.8
> Reporter: Carl Zhu
> Fix For: 3.0.13, 3.1.11, 3.2.0
>
>
> The http request:
> GET /dubbott-demo-provider/v1.0/users/beanparam?a=&b= HTTP/1.1
> HOST: localhost:8080
> accept: application/json
> content-type: application/json
> The resource method returns null:
> public String beanParam(@QueryParam("a") Integer a, @QueryParam("b")
> Integer b) {
> return a+b;
> }
> javax.ws.rs.ClientErrorException: HTTP 404 Not Found
> at
> org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:117)
> at
> org.apache.cxf.jaxrs.utils.ExceptionUtils.toHttpException(ExceptionUtils.java:169)
> at
> org.apache.cxf.jaxrs.utils.InjectionUtils.handleParameter(InjectionUtils.java:472)
> at
> org.apache.cxf.jaxrs.utils.InjectionUtilsTest.testInstantiateSimpleTypeInQuery(InjectionUtilsTest.java:154)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
> at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
> at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
> Caused by: java.lang.NumberFormatException: For input string: ""
> at
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
> at java.lang.Integer.parseInt(Integer.java:592)
> at java.lang.Integer.<init>(Integer.java:867)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> at
> org.apache.cxf.jaxrs.utils.InjectionUtils.handleParameter(InjectionUtils.java:461)
> ... 23 more
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)