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

Do not append single '&' with empty query parameters

XMLWordPrintable

      RESTEasy is considering empty collections in query parameters for building the URL. This leads to strange results. E.g. http://www.something.org/someResource?& in the example below:

      public class Reproducer {
      
          @Path("someResource")
          @Produces(MediaType.APPLICATION_JSON)
          @Consumes(MediaType.APPLICATION_JSON)
          public interface SomeResource {
      
              @GET
              void methodWIthList(@QueryParam("listA") List<String> listA, @QueryParam("listB") List<String> listB);
          }
      
          public static void main(String[] args) {
              ResteasyClientBuilder builder = (ResteasyClientBuilder) ClientBuilder.newBuilder();
              builder.httpEngine(new ClientHttpEngine() {
      
                  @Override
                  public Response invoke(Invocation request) {
                      System.out.println(((ClientInvocation) request).getUri());
      
                      // http://www.something.org/someResource?&
      
                      return new AbortedResponse(null, new ServerResponse());
                  }
      
                  @Override
                  public SSLContext getSslContext() {
                      return null;
                  }
      
                  @Override
                  public HostnameVerifier getHostnameVerifier() {
                      return null;
                  }
      
                  @Override
                  public void close() {}
              }).build().target("http://www.something.org").proxy(SomeResource.class).methodWIthList(List.of(), List.of());
          }
      }

       

              dkafe Dimitris Kafetzis
              thomas-wb Thomas TWB (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: