Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-591

Client request invoked via a ClientProxy built by ProxyFactory corrupts string parameters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 2.3-beta-1
    • 2.0.1.GA
    • jaxrs
    • None
    • Hide

      Specifically, I updated TestClient.java and MyTestResource.java to have a new method:

         @GET
         @Produces("text/plain")
         @Path("/query-param")
         public ClientResponse<String> getQueryParam(@QueryParam("queryParam") String queryParam);
      

      I then added the following tests to EncodingTest.java (which mimic the encodingCharacter() method contained therein):

         @Test
         public void testPathParamWithDoublePercent() {
             String paramWithDoublePercent = "start%%end";
             System.out.println("*** " + paramWithDoublePercent);
             ClientResponse<String> returned = testClient.getPathParam(paramWithDoublePercent);
             Assert.assertNotNull(returned);
             Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus());
             Assert.assertEquals(paramWithDoublePercent, returned.getEntity());
         }
      
         @Test
         public void testPathParamWithBraces() {
             String paramWithBraces = "start{param}end";
             System.out.println("*** " + paramWithBraces);
             ClientResponse<String> returned = testClient.getPathParam(paramWithBraces);
             Assert.assertNotNull(returned);
             Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus());
             Assert.assertEquals(paramWithBraces, returned.getEntity());
         }
      
         @Test
         public void testPathParamWithLifePercentDeath() {
             String paramWithLifePercentDeath = "life%death";
             System.out.println("*** " + paramWithLifePercentDeath);
             ClientResponse<String> returned = testClient.getPathParam(paramWithLifePercentDeath);
             Assert.assertNotNull(returned);
             Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus());
             Assert.assertEquals(paramWithLifePercentDeath, returned.getEntity());
         }
      
         @Test
         public void testQueryParamWithDoublePercent() {
             String paramWithDoublePercent = "start%%end";
             System.out.println("*** " + paramWithDoublePercent);
             ClientResponse<String> returned = testClient.getQueryParam(paramWithDoublePercent);
             Assert.assertNotNull(returned);
             Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus());
             Assert.assertEquals(paramWithDoublePercent, returned.getEntity());
         }
      
         @Test
         public void testQueryParamWithBraces() {
             String paramWithBraces = "start{param}end";
             System.out.println("*** " + paramWithBraces);
             ClientResponse<String> returned = testClient.getQueryParam(paramWithBraces);
             Assert.assertNotNull(returned);
             Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus());
             Assert.assertEquals(paramWithBraces, returned.getEntity());
         }
      
         @Test
         public void testQueryParamWithLifePercentDeath() {
             String paramWithLifePercentDeath = "life%death";
             System.out.println("*** " + paramWithLifePercentDeath);
             ClientResponse<String> returned = testClient.getQueryParam(paramWithLifePercentDeath);
             Assert.assertNotNull(returned);
             Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus());
             Assert.assertEquals(paramWithLifePercentDeath, returned.getEntity());
         }
      

      The summary of the test run follows:

        Results :
      
        Failed tests:
          testPathParamWithLifePercentDeath(org.jboss.resteasy.test.encoding.EncodingTest)
          testQueryParamWithLifePercentDeath(org.jboss.resteasy.test.encoding.EncodingTest)
      
        Tests in error:
          testPathParamWithDoublePercent(org.jboss.resteasy.test.encoding.EncodingTest)
          testPathParamWithBraces(org.jboss.resteasy.test.encoding.EncodingTest)
          testQueryParamWithDoublePercent(org.jboss.resteasy.test.encoding.EncodingTest)
          testQueryParamWithBraces(org.jboss.resteasy.test.encoding.EncodingTest)
      

      Note that four of the test results in exceptions occuring within RestEASY code. The two failed tests fail because the value returned does not equal the value passed as a parameter.

      Show
      Specifically, I updated TestClient.java and MyTestResource.java to have a new method: @GET @Produces("text/plain") @Path("/query-param") public ClientResponse<String> getQueryParam(@QueryParam("queryParam") String queryParam); I then added the following tests to EncodingTest.java (which mimic the encodingCharacter() method contained therein): @Test public void testPathParamWithDoublePercent() { String paramWithDoublePercent = "start%%end"; System.out.println("*** " + paramWithDoublePercent); ClientResponse<String> returned = testClient.getPathParam(paramWithDoublePercent); Assert.assertNotNull(returned); Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus()); Assert.assertEquals(paramWithDoublePercent, returned.getEntity()); } @Test public void testPathParamWithBraces() { String paramWithBraces = "start{param}end"; System.out.println("*** " + paramWithBraces); ClientResponse<String> returned = testClient.getPathParam(paramWithBraces); Assert.assertNotNull(returned); Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus()); Assert.assertEquals(paramWithBraces, returned.getEntity()); } @Test public void testPathParamWithLifePercentDeath() { String paramWithLifePercentDeath = "life%death"; System.out.println("*** " + paramWithLifePercentDeath); ClientResponse<String> returned = testClient.getPathParam(paramWithLifePercentDeath); Assert.assertNotNull(returned); Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus()); Assert.assertEquals(paramWithLifePercentDeath, returned.getEntity()); } @Test public void testQueryParamWithDoublePercent() { String paramWithDoublePercent = "start%%end"; System.out.println("*** " + paramWithDoublePercent); ClientResponse<String> returned = testClient.getQueryParam(paramWithDoublePercent); Assert.assertNotNull(returned); Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus()); Assert.assertEquals(paramWithDoublePercent, returned.getEntity()); } @Test public void testQueryParamWithBraces() { String paramWithBraces = "start{param}end"; System.out.println("*** " + paramWithBraces); ClientResponse<String> returned = testClient.getQueryParam(paramWithBraces); Assert.assertNotNull(returned); Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus()); Assert.assertEquals(paramWithBraces, returned.getEntity()); } @Test public void testQueryParamWithLifePercentDeath() { String paramWithLifePercentDeath = "life%death"; System.out.println("*** " + paramWithLifePercentDeath); ClientResponse<String> returned = testClient.getQueryParam(paramWithLifePercentDeath); Assert.assertNotNull(returned); Assert.assertEquals(HttpURLConnection.HTTP_OK, returned.getStatus()); Assert.assertEquals(paramWithLifePercentDeath, returned.getEntity()); } The summary of the test run follows: Results : Failed tests: testPathParamWithLifePercentDeath(org.jboss.resteasy.test.encoding.EncodingTest) testQueryParamWithLifePercentDeath(org.jboss.resteasy.test.encoding.EncodingTest) Tests in error: testPathParamWithDoublePercent(org.jboss.resteasy.test.encoding.EncodingTest) testPathParamWithBraces(org.jboss.resteasy.test.encoding.EncodingTest) testQueryParamWithDoublePercent(org.jboss.resteasy.test.encoding.EncodingTest) testQueryParamWithBraces(org.jboss.resteasy.test.encoding.EncodingTest) Note that four of the test results in exceptions occuring within RestEASY code. The two failed tests fail because the value returned does not equal the value passed as a parameter.

      The RestEASY client code does not properly process certain values passed to @PathParam and @QueryParam parameters. For example, a parameter value of "start%%end" results in

        RuntimeException: java.lang.RuntimeException: Failed to create URI: http://localhost:1889/test/path-param/start%25%end
      

      I updated the EncodingTest to illustrate the problem. See Steps to Reproduce for details. Note that I ran the repro case against both 2.0.1.GA and the current trunk.

        1. EncodingTest.java
          19 kB
          Mark Malynn
        2. MyTestResource.java
          0.6 kB
          Mark Malynn
        3. org.jboss.resteasy.test.encoding.EncodingTest.txt
          21 kB
          Mark Malynn
        4. resteasy-519-trunk-patch.txt
          11 kB
          Mark Malynn
        5. resteasy-591-patch.txt
          11 kB
          Mark Malynn
        6. TestClient.java
          0.6 kB
          Mark Malynn

              patriot1burke@gmail.com Bill Burke (Inactive)
              mark.malynn Mark Malynn (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: