cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stian Soiland-Reyes (JIRA)" <>
Subject [jira] [Commented] (CXF-4919) UriInfo.relativize (and HttpUtils.relativize) broken
Date Mon, 22 Apr 2013 01:06:13 GMT


Stian Soiland-Reyes commented on CXF-4919:

Sorry for the wait, I was waiting for our legal department to clear the contributors agreement,
in the end I just did it from scratch in my spare time at home. I did not look at nor use
the similar (but in retrospect subtly different) algorithm I wrote in 2011 for my employer.

Here's the suggested patch:

The algorithm uses Java's URI.relativize(), but if needed climbs up to find a common parent
(as URI.relativize will refuse to do "../"). It has a requirement that the base URI must already
be absolute; ie "" rather than "/base/root/" - I can make that
supported as well, but that must be done carefully.

I just created the code of the above patch in my personal time, and should therefore not depend
on the my employers (pending) contributors license assignment.

I am still waiting for the cxf-systests-jaxrs to complete and will let you know if they fail
due to this. 
> UriInfo.relativize (and HttpUtils.relativize) broken
> ----------------------------------------------------
>                 Key: CXF-4919
>                 URL:
>             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("");
>         URI abcd = URI.create("");
>         assertEquals("", HttpUtils.relativize(ab, ab));
>         assertEquals(URI.create("c/d"), HttpUtils.relativize(ab, abcd));
>         assertEquals(URI.create("../"), HttpUtils.relativize(abcd, ab));
>         assertEquals("", HttpUtils.relativize(abcd, abcd));
>         URI abcd2 = URI.create("");
>         assertEquals(URI.create("d2"), HttpUtils.relativize(abcd, abcd2));
>         URI ab2cd = URI.create("");
>         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:

View raw message