-
Bug
-
Resolution: Duplicate
-
Major
-
jboss-fuse-6.3
-
None
-
%
-
I have a simple camel-cxf rsServer endpoint and address is configured with a relative path so it will use Pax Web port:
<camelcxf:rsServer id="restService" address="/api" loggingFeatureEnabled="true" serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" />
And here is the GET operation in the service class:
@GET @Path("/customer/{id}") @Produces("application/customer+xml") public Response getCustomer(@PathParam("id") String id) {...}
However, when I sent a HTTP GET request with empty space encoded with "%20" in the URL as a @PathParam, for instance:
http://localhost:8181/cxf/api/customer/123%20222
I was getting this error:
17:34:14,824 | WARN | qtp1074228257-86 | ServletHandler | 96 - org.eclipse.jetty.util - 9.2.19.v20160908 | /cxf/api/customer/123 222 java.lang.IllegalArgumentException: Illegal character in path at index 43: http://localhost:8181/cxf/api/customer/123 222 at java.net.URI.create(URI.java:852)[:1.8.0_66] at org.apache.cxf.transport.servlet.BaseUrlHelper.getBaseURL(BaseUrlHelper.java:48)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187] at org.apache.cxf.transport.servlet.ServletController.getBaseURL(ServletController.java:74)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187] ... Caused by: java.net.URISyntaxException: Illegal character in path at index 43: http://localhost:8181/cxf/api/customer/123 222 at java.net.URI$Parser.fail(URI.java:2848)[:1.8.0_66] at java.net.URI$Parser.checkChars(URI.java:3021)[:1.8.0_66] ...
Further investigation showed that if I change to http-jetty transport (configure a standalone port on the camel-cxf rsServer endpoint), for instance:
<camelcxf:rsServer id="restService" address="http://0.0.0.0:9081/api" loggingFeatureEnabled="true" serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" />
Then the percent encoding for empty space "%20" works fine.
I also found this upstream JIRA:
https://issues.apache.org/jira/browse/CXF-4446
It was created a while ago but closed without any fix. And from my debug session, I can see that the Pax Web takes in "%20" encoded empty space but gives back a decoded URL with an empty space in it to CXF. And CXF just simply uses the decoded URL and hence caused the java.net.URISyntaxException indeed.
I wonder that is it possible to fix it so percent encoding "%20" for empty space (SP) can be supported in CXF servlet transport too, just same as http-jetty transport?
- duplicates
-
ENTESB-5856 Camel CXF REST application throws 500 HTTP error when query-param is sent with a space in between
- Closed