[ https://issues.apache.org/jira/browse/CXF-4919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13637880#comment-13637880 ]
Sergey Beryozkin commented on CXF-4919: --------------------------------------- Hi Stian, thanks for the effort, > It has a requirement that the base URI must already be absolute I think this is what the JAX-RS expectation is too, see bullet 1 at https://jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/javax/ws/rs/core/UriInfo.html#relativize(java.net.URI) (If the URI to relativize needs to become absolute then obviously the base has to be absolute too). Regarding https://java.net/jira/browse/JAX_RS_SPEC-398, I can not access it, may be you need to update the permissions on it (who can see it and such ?). FYI, I'm not sure what is wrong with: {noformat} Request URI: http://host:port/app/root/a/b/c Supplied URI: a/b/c/d/e Returned URI: d/e {noformat} According to http://docs.oracle.com/javase/6/docs/api/java/net/URI.html, {noformat} u.resolve(u.relativize(v)).equals(v) {noformat} and resolving "d/e" against "http://host:port/app/root/a/b/c" should produce "http://host:port/app/root/a/b/c/d/e" Actually, I think I see the doc bug, should be {noformat} Request URI: http://host:port/app/root/a/b/c/ Supplied URI: a/b/c/d/e Returned URI: d/e {noformat} Right ? > UriInfo.relativize (and HttpUtils.relativize) broken > ---------------------------------------------------- > > Key: CXF-4919 > URL: https://issues.apache.org/jira/browse/CXF-4919 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 2.7.3 > Reporter: Stian Soiland-Reyes > > None of these tests pass: > {code} > > @Test > public void testRelativize() throws Exception { > URI ab = URI.create("http://example.com/a/b/"); > URI abcd = URI.create("http://example.com/a/b/c/d"); > assertEquals(URI.create(""), HttpUtils.relativize(ab, ab)); > assertEquals(URI.create("c/d"), HttpUtils.relativize(ab, abcd)); > assertEquals(URI.create("../"), HttpUtils.relativize(abcd, ab)); > assertEquals(URI.create(""), HttpUtils.relativize(abcd, abcd)); > URI abcd2 = URI.create("http://example.com/a/b/c/d2"); > assertEquals(URI.create("d2"), HttpUtils.relativize(abcd, abcd2)); > URI ab2cd = URI.create("http://example.com/a/b2/c/d"); > assertEquals(URI.create("../../b2/c/d"), HttpUtils.relativize(abcd, > ab2cd)); > } > {code} > This affects LinkBuilder.buildRelativize() and UriInfo.relativize() > The algorithm is basically working by counting elements common by position - > this would also fail hard when there are common elements later - but with a > different ancestor. > Javadoc for UriInfo.relativize() also has some testcases that should work. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira