Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4919

UriInfo.relativize (and HttpUtils.relativize) broken

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.3
    • Fix Version/s: 3.0.0-milestone1
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      None of these tests pass:

        
          @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));
          }
      

      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.

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              soilandreyes Stian Soiland-Reyes (old) (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: