Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-4707

ContainerRequestContext setRequestUri doesn't clear previous query parameters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.0.1.CR1, 7.0.1.GA
    • None
    • REST
    • None
    • Hide

      As a workaround, you'd want to first clear the existing query parameters before calling setRequestUri, which is fortunately possible because UriInfo.getQueryParameters erroneously returns a mutable map. Be sure to clear both unencoded and encoded parameters:

      // Start workaround for this issue
      requestContext.getUriInfo().getQueryParameters(false).clear();
      requestContext.getUriInfo().getQueryParameters(true).clear();
      // end workaround
      requestContext.setRequestUri(newBaseUri, newRequestUri);
      
      Show
      As a workaround, you'd want to first clear the existing query parameters before calling setRequestUri , which is fortunately possible because UriInfo.getQueryParameters erroneously returns a mutable map. Be sure to clear both unencoded and encoded parameters: // Start workaround for this issue requestContext.getUriInfo().getQueryParameters( false ).clear(); requestContext.getUriInfo().getQueryParameters( true ).clear(); // end workaround requestContext.setRequestUri(newBaseUri, newRequestUri);
    • EAP 7.0.1

      As a followup to RESTEASY-1099, when calling setRequestUri, the current query parameters aren't cleared, and new query parameters are merged into existing ones.

      In my specific case (OAuth/OpenID Connect implementation, setRequestUri being called from a pre-matching filter to rewrite the URI depending on X-Forwarded-Proto), the problem is that having parameters appearing more than once is seen as an error (even if repeated with the same value). So my filter (see code snippet in RESTEASY-1099) is breaking my downstream resource by artificially duplicating the query parameters.

      Note that the workaround highlights another bug: UriInfo.getQueryParameters returns mutable maps.

              mstefank Martin Stefanko
              t.broyer Thomas Broyer (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: