[ https://issues.apache.org/jira/browse/CXF-2652?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julien Wajsberg updated CXF-2652: --------------------------------- Description: I tried this simple code : {code} package mypackage; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; @Path("uri") public class UriService { @GET @Path("something/{id}") public void addSomething(String string, @Context UriInfo uriInfo, @PathParam("id") String id) { System.out.println("getPath -> " + uriInfo.getPath()); System.out.println("getBasePath -> " + uriInfo.getBaseUri()); System.out.println("getAbsolutePath -> " + uriInfo.getBaseUri().resolve(uriInfo.getPath(false))); System.out.println("getAbsolutePath -> " + uriInfo.getAbsolutePath()); } } {code} With a Spring-based setup and default beans.xml taken from the user guide. Then we can use a normal browser . With "http://localhost:9080/Uritest/rest/uri/something/3", we get in stdout : {panel} getPath -> /uri/something/3 getBasePath -> http://localhost:9080/Uritest/rest getAbsolutePath -> http://localhost:9080/uri/something/3 getAbsolutePath -> http://localhost:9080/Uritest/rest/uri/something/3 {panel} But with "http://localhost:9080/Uritest/rest/uri/something/3 4", we get an exception : java.net.URISyntaxException: Illegal character in path at index 50: http://localhost:9080/Uritest/rest/uri/something/3 4 And in stdout : {panel} getPath -> /uri/something/3 4 getBasePath -> http://localhost:9080/Uritest/rest getAbsolutePath -> http://localhost:9080/uri/something/3%204 {panel} NB : in JAX-RS javadoc, it's said that "getAbsolutePath()" is a shortcut to uriInfo.getBase().resolve(uriInfo.getPath())", which is plain wrong, because : # getBase doesn't exist, that's getBaseUri # getPath as returned by CXF begins with a slash ("/") so "resolve" doesn't do what we want here. was: I tried this simple code : package mypackage; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; @Path("uri") public class UriService { @GET @Path("something/{id}") public void addSomething(String string, @Context UriInfo uriInfo, @PathParam("id") String id) { System.out.println("getPath -> " + uriInfo.getPath()); System.out.println("getBasePath -> " + uriInfo.getBaseUri()); System.out.println("getAbsolutePath -> " + uriInfo.getBaseUri().resolve(uriInfo.getPath(false))); System.out.println("getAbsolutePath -> " + uriInfo.getAbsolutePath()); } } With a Spring-based setup and default beans.xml taken from the user guide. Then we can use a normal browser . With "http://localhost:9080/Uritest/rest/uri/something/3", we get in stdout : getPath -> /uri/something/3 getBasePath -> http://localhost:9080/Uritest/rest getAbsolutePath -> http://localhost:9080/uri/something/3 getAbsolutePath -> http://localhost:9080/Uritest/rest/uri/something/3 But with "http://localhost:9080/Uritest/rest/uri/something/3 4", we get an exception : java.net.URISyntaxException: Illegal character in path at index 50: http://localhost:9080/Uritest/rest/uri/something/3 4 And in stdout : getPath -> /uri/something/3 4 getBasePath -> http://localhost:9080/Uritest/rest getAbsolutePath -> http://localhost:9080/uri/something/3%204 NB : in JAX-RS javadoc, it's said that "getAbsolutePath()" is a shortcut to uriInfo.getBase().resolve(uriInfo.getPath())", which is plain wrong, because : 1 - getBase doesn't exist, that's getBaseUri 2 - getPath as returned by CXF begins with a slash ("/") so "resolve" doesn't do what we want here. > UriInfo.getAbsolutePath throws "java.net.URISyntaxException: Illegal > character in path" when there is an encoded space in the request URI > ----------------------------------------------------------------------------------------------------------------------------------------- > > Key: CXF-2652 > URL: https://issues.apache.org/jira/browse/CXF-2652 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 2.2.6 > Environment: Used with Spring > Reporter: Julien Wajsberg > > I tried this simple code : > {code} > package mypackage; > import javax.ws.rs.GET; > import javax.ws.rs.Path; > import javax.ws.rs.PathParam; > import javax.ws.rs.core.Context; > import javax.ws.rs.core.UriInfo; > @Path("uri") > public class UriService { > @GET > @Path("something/{id}") > public void addSomething(String string, @Context UriInfo uriInfo, > @PathParam("id") String id) { > System.out.println("getPath -> " + uriInfo.getPath()); > System.out.println("getBasePath -> " + uriInfo.getBaseUri()); > System.out.println("getAbsolutePath -> " + > uriInfo.getBaseUri().resolve(uriInfo.getPath(false))); > System.out.println("getAbsolutePath -> " + uriInfo.getAbsolutePath()); > } > } > {code} > With a Spring-based setup and default beans.xml taken from the user guide. > Then we can use a normal browser . > With "http://localhost:9080/Uritest/rest/uri/something/3", we get in stdout : > {panel} > getPath -> /uri/something/3 > getBasePath -> http://localhost:9080/Uritest/rest > getAbsolutePath -> http://localhost:9080/uri/something/3 > getAbsolutePath -> http://localhost:9080/Uritest/rest/uri/something/3 > {panel} > But with "http://localhost:9080/Uritest/rest/uri/something/3 4", we get an > exception : > java.net.URISyntaxException: Illegal character in path at index 50: > http://localhost:9080/Uritest/rest/uri/something/3 4 > And in stdout : > {panel} > getPath -> /uri/something/3 4 > getBasePath -> http://localhost:9080/Uritest/rest > getAbsolutePath -> http://localhost:9080/uri/something/3%204 > {panel} > NB : in JAX-RS javadoc, it's said that "getAbsolutePath()" is a shortcut to > uriInfo.getBase().resolve(uriInfo.getPath())", which is plain wrong, because : > # getBase doesn't exist, that's getBaseUri > # getPath as returned by CXF begins with a slash ("/") so "resolve" doesn't > do what we want here. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.