Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8387

Allow special characters to be used for a queryParam name.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3.7, 3.4.3
    • Fix Version/s: 3.4.4, 3.3.11, 3.5.0
    • Component/s: JAX-RS
    • Labels:
      None
    • Environment:
    • Estimated Complexity:
      Unknown

      Description

      Customer would like to use ("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@", "apiKeyQueryParam1Value" ) as a queryParam. The get fails with a javax.ws.rs.core.UriBuilderException: URI can not be built.

              Response response = client.target("http://localhost:" + "8010" + "/paramconverter/")
                              .path("application/resource/queryParamSpecialCharacters")
                              .queryParam("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@", "apiKeyQueryParam1Value")
                              .request(MediaType.APPLICATION_JSON_TYPE)
                              .get();
      
          @GET
          @Path("queryParamSpecialCharacters")
          public Response queryParamSpecialCharacters(@QueryParam("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@") final String queryParm1) {
              System.out.println("queryParamSpecialCharacters queryParm1 = " + queryParm1);
              return Response.ok(queryParm1).build();
          }
      
      [12/8/20, 8:54:22:004 CST] 00000076 SystemErr                                                    R javax.ws.rs.core.UriBuilderException: URI can not be built
      	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuild(UriBuilderImpl.java:120)
      	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.buildFromEncoded(UriBuilderImpl.java:245)
      	at org.apache.cxf.jaxrs.client.AbstractClient.getCurrentURI(AbstractClient.java:319)
      	at org.apache.cxf.jaxrs.client.WebClient.fromClient(WebClient.java:315)
      	at org.apache.cxf.jaxrs.client.WebClient.fromClient(WebClient.java:295)
      	at org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTargetImpl.request(ClientImpl.java:373)
      	at org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTargetImpl.request(ClientImpl.java:438)
      	at com.ibm.ws.jaxrs.fat.paramconverter.ClientTestServlet.testQueryParamSpecialCharacters(ClientTestServlet.java:256)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      	at componenttest.app.FATServlet.doGet(FATServlet.java:71)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
      	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1257)
      	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:745)
      	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:442)
      	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1226)
      	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5057)
      	at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:314)
      	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1005)
      	at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:279)
      	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1141)
      	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:422)
      	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:381)
      	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:565)
      	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:499)
      	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:359)
      	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:326)
      	at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:167)
      	at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:75)
      	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504)
      	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574)
      	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:958)
      	at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1047)
      	at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:239)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:831)
      Caused by: java.net.URISyntaxException: Illegal character in query at index 154: http://localhost:8010/paramconverter/application/resource/queryParamSpecialCharacters?/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~�!$'()* ,;:@=apiKeyQueryParam1Value
      	at java.base/java.net.URI$Parser.fail(URI.java:2915)
      	at java.base/java.net.URI$Parser.checkChars(URI.java:3086)
      	at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3174)
      	at java.base/java.net.URI$Parser.parse(URI.java:3116)
      	at java.base/java.net.URI.<init>(URI.java:600)
      	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.buildURIFromEncoded(UriBuilderImpl.java:202)
      	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.buildURI(UriBuilderImpl.java:175)
      	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuild(UriBuilderImpl.java:118)
      	... 39 more
      

      I tried the suggested workaround to encode the queryParam name twice.

              Response response = client.target(URI_CONTEXT_ROOT)
                              .path("application/resource/queryParamSpecialCharacters")
                              .queryParam(URLEncoder.encode(URLEncoder.encode("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@", "UTF-8"), "UTF-8"), "apiKeyQueryParam1Value")
                              .request(MediaType.APPLICATION_JSON_TYPE)
                              .get();
      
          @GET
          @Path("queryParamSpecialCharacters")
          public Response queryParamSpecialCharacters(@QueryParam("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@") String queryParm1) {
              System.out.println("queryParamSpecialCharacters queryParm1 = " + queryParm1);
              return Response.ok(queryParm1).build();
          }
      

      I no longer get the error javax.ws.rs.core.UriBuilderException: URI can not be built. . Unfortunately the test fails in a different way. The queryParam value is set to null.

      SystemOut                                                    O queryParamSpecialCharacters queryParm1 = null
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                reta Andriy Redko
                Reporter:
                jkoehler22 John Koehler
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: