From 4b06c5550a9d00b064e804d98308eb25e1939440 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Mon, 1 Mar 2021 15:07:54 +1100 Subject: [PATCH] Fix issue with double query params --- .../reactive/server/test/resource/basic/UriInfoTest.java | 5 +++++ .../test/resource/basic/resource/UriInfoSimpleResource.java | 6 ++++++ .../jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/UriInfoTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/UriInfoTest.java index 9025f8323459c..fa6194b91bb72 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/UriInfoTest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/UriInfoTest.java @@ -8,6 +8,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; +import org.hamcrest.Matchers; import org.jboss.logging.Logger; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; @@ -27,6 +28,7 @@ import io.quarkus.resteasy.reactive.server.test.resource.basic.resource.UriInfoSimpleSingletonResource; import io.quarkus.resteasy.reactive.server.test.simple.PortProviderUtil; import io.quarkus.test.QuarkusUnitTest; +import io.restassured.RestAssured; /** * @tpSubChapter Resources @@ -77,6 +79,9 @@ public static void after() throws Exception { public void testUriInfo() throws Exception { basicTest("/simple", UriInfoSimpleResource.class.getSimpleName()); basicTest("/simple/fromField", UriInfoSimpleResource.class.getSimpleName()); + + RestAssured.get("/" + UriInfoSimpleResource.class.getSimpleName() + "/uri?foo=bar").then() + .body(Matchers.endsWith("/uri?foo=bar")); } /** diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/UriInfoSimpleResource.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/UriInfoSimpleResource.java index 9d88885907f11..7ba33b4faa167 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/UriInfoSimpleResource.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/UriInfoSimpleResource.java @@ -38,6 +38,12 @@ public String get(@Context UriInfo info, @QueryParam("abs") String abs) { return "CONTENT"; } + @Path("/uri") + @GET + public String get(@Context UriInfo info) { + return info.getRequestUri().toASCIIString(); + } + @Path("/simple/fromField") @GET public String getField(@QueryParam("abs") String abs) { diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java index e669820eb2cf8..17cb32fb312a3 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java @@ -71,7 +71,7 @@ public URI getRequestUri() { ServerHttpRequest request = currentRequest.serverRequest(); try { // TCK says normalized - requestUri = new URI(currentRequest.getAbsoluteURI() + (request.query() == null ? "" : "?" + request.query())) + requestUri = new URI(currentRequest.getAbsoluteURI()) .normalize(); } catch (URISyntaxException e) { throw new RuntimeException(e);