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

UriInfo.relativize (and HttpUtils.relativize) broken

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.3
    • 3.0.0-milestone1
    • JAX-RS
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: