jersey
  1. jersey
  2. JERSEY-1369

UriBuilder doesn't deal with Matrix parameter properly when there is a path sub element

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.13
    • Fix Version/s: 2.0-m09
    • Component/s: None
    • Labels:
      None

      Description

      Consider these two tests along with the current test failures, it seems like UriBuilder doesn't deal with matrix parameters at multiple levels of the URI properly.

      package client2;
      
      import javax.ws.rs.core.UriBuilder;
      
      import org.junit.Assert;
      import org.junit.Test;
      
      public class UriBuilderMAtrix {
      
      
          @Test
          public  void sameName() {
              UriBuilder first = UriBuilder.fromUri("http://www.com/").replaceMatrixParam("example", "one", "two");
              first = first.path("/child");
              System.out.println(first.build());
              first = first.replaceMatrixParam("example", "another");
              
              Assert.assertEquals(
                  "http://www.com/;example=one;example=two/child;example=another", first.build());
              // java.lang.AssertionError: expected:<http://www.com/;example=one;example=two/child;example=another> but was:<http://www.com/;example=another>
          }
      
          @Test
          public  void different() {
              UriBuilder first = UriBuilder.fromUri("http://www.com/").replaceMatrixParam("example", "one", "two");
              first = first.path("/child");
              System.out.println(first.build());
              first = first.replaceMatrixParam("other", "another");
      
              Assert.assertEquals(
                  "http://www.com/;example=one;example=two/child;other=another", first.build());
              // java.lang.AssertionError: expected:<http://www.com/;example=one;example=two/child;other=another> but was:<http://www.com/;other=another;example=one;example=two/child>
          }
      }
      

      Note that the documentation for UriBuilder.replaceMatrix states:

      "Note that the matrix parameters are tied to a particular path segment; subsequent addition of path segments will not affect their position in the URI path."

      So it should be possible to modify matrix parameters at different levels of the path without affecting the others

        Activity

        Hide
        Martin Matula added a comment -

        Pavel, please look into this. You may want to sync up with Marek if any clarifications need to be added to the spec.

        Show
        Martin Matula added a comment - Pavel, please look into this. You may want to sync up with Marek if any clarifications need to be added to the spec.
        Hide
        Miroslav Fuksa added a comment -

        Fixed by JERSEY-1415.

        Show
        Miroslav Fuksa added a comment - Fixed by JERSEY-1415 .
        Hide
        Miroslav Fuksa added a comment -

        Fixed by JERSEY-1415.

        Show
        Miroslav Fuksa added a comment - Fixed by JERSEY-1415 .

          People

          • Assignee:
            Miroslav Fuksa
            Reporter:
            gdavison
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 20 minutes
              20m