Skip to content

Commit

Permalink
quarkus-rest-client-reactive does not URL encode some @QueryParam va…
Browse files Browse the repository at this point in the history
…lues issue quarkusio#24426
  • Loading branch information
plevart committed Mar 20, 2022
1 parent 05c1092 commit 4f87360
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2328,10 +2328,11 @@ private ResultHandle addQueryParam(BytecodeCreator methodCreator,
Class.class, java.lang.reflect.Type.class, Annotation[].class),
client, paramArray, notNullValue.loadClassFromTCCL(componentType), genericType, paramAnnotations);

notNullValue.assign(result, notNullValue.invokeInterfaceMethod(
MethodDescriptor.ofMethod(WebTarget.class, "queryParam", WebTarget.class,
ResultHandle targetImpl = notNullValue.checkCast(target, WebTargetImpl.class);
notNullValue.assign(result, notNullValue.invokeVirtualMethod(
MethodDescriptor.ofMethod(WebTargetImpl.class, "queryParamNoTemplate", WebTargetImpl.class,
String.class, Object[].class),
target, notNullValue.load(paramName), paramArray));
targetImpl, notNullValue.load(paramName), paramArray));

BytecodeCreator nullValue = isValueNull.trueBranch();
nullValue.assign(result, nullValue.loadNull());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package io.quarkus.jaxrs.client.reactive.deployment.test;

import io.quarkus.test.QuarkusUnitTest;
import io.quarkus.test.common.http.TestHTTPResource;
import io.vertx.core.Handler;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import org.jboss.resteasy.reactive.client.impl.UniInvoker;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.net.URL;
import java.util.stream.Collectors;
import javax.enterprise.event.Observes;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

public class QueryParamNoTemplateTestCase {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClasses(Endpoint.class));

@TestHTTPResource
URL url;

private Client client;

@BeforeEach
public void before() {
client = ClientBuilder.newBuilder().build();
}

@AfterEach
public void after() {
client.close();
}

@Test
public void testInjection() {
Object data = client.target(url.toExternalForm() + "/hello")
.queryParam("param", "{foo&bar}", "%FF")
.request()
.rx(UniInvoker.class)
.get()
.await()
.indefinitely();
Assertions.assertEquals("{foo&bar},%FF", data);
}

public static class Endpoint {

public void setup(@Observes Router router) {
router.route("/hello").handler(new Handler<RoutingContext>() {
@Override
public void handle(RoutingContext event) {
event.response()
.end(
event.queryParam("param")
.stream()
.sorted()
.collect(Collectors.joining(","))
);
}
});
}

}

}

0 comments on commit 4f87360

Please sign in to comment.