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

@javax.ws.rs.Encoded not working

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 2.2.1
    • jaxrs
    • None
    • Hide

      Create a JAX-RS annotated interface:

      public interface RestEasyClient {

      @GET
      @Path("

      {searchParams}

      ")
      public String search( @PathParam("searchParams") @Encoded String searchParams);
      }

      Build a client proxy using something similar to:
      ResteasyProviderFactory restEasyProviderFactory = new ResteasyProviderFactory();
      RegisterBuiltin.register(this.restEasyProviderFactory);
      final ClientExecutor httpExecutor = new ApacheHttpClient4Executor(apacheClient);
      RestEasyClient client = (RestEasyClient )ProxyFactory.create(RestEasyClient.class,"Some EndPoint", httpExecutor,
      this.restEasyProviderFactory);

      client.search("/solr/5159200/select?param1=value&param2=value");

      Show
      Create a JAX-RS annotated interface: public interface RestEasyClient { @GET @Path(" {searchParams} ") public String search( @PathParam("searchParams") @Encoded String searchParams); } Build a client proxy using something similar to: ResteasyProviderFactory restEasyProviderFactory = new ResteasyProviderFactory(); RegisterBuiltin.register(this.restEasyProviderFactory); final ClientExecutor httpExecutor = new ApacheHttpClient4Executor(apacheClient); RestEasyClient client = (RestEasyClient )ProxyFactory.create(RestEasyClient.class,"Some EndPoint", httpExecutor, this.restEasyProviderFactory); client.search("/solr/5159200/select?param1=value&param2=value");

    Description

      I am using RestEasy 2.2.1.GA Client Framework. I have a '?' in my PathParam that I do not want encoded, I tried using the javax.ws.rs.Encoded annotation (tried it on all field, method and class) but it still gets converted to a %3F in the eventual URI that gets invoked causing my request to fail.

      Debugging the code I noticed that the URI to be invoked is obtained from org.jboss.resteasy.client.ClientRequest.getUri() which in turn calls (Line 782) UriBuilderImpl. substitutePathParam(String name, Object value, boolean isEncoded); The value for isEncode parameter, the last parameter of substitutePathParam(), is hard coded to 'false', if I change it to true in eclipse debug mode, my call works fine.

      Should ClientRequest.getUri(), instead of passing a hard coded value of false to UriBuilderImpl.substitutePathParam(String name, Object value, boolean isEncoded) for isEncoded parameter, introspect for @Encoded annotation and pass the appropriate Boolean value.

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            sandeeptikoo SANDEEP TIKOO (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: