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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Done
    • 2.0.1.GA
    • 2.3-beta-1
    • 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.

    Description

      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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: