diff --git a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/AbstractHttpClient.java b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/AbstractHttpClient.java index 05a1f613..45a7cdb0 100644 --- a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/AbstractHttpClient.java +++ b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/AbstractHttpClient.java @@ -4,11 +4,14 @@ import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.MultiMap; +import io.vertx.core.Vertx; import io.vertx.core.http.*; import java.util.List; import java.util.function.Function; +import static io.vertx.core.Future.succeededFuture; + /** * Base class with empty method implementations. * @@ -16,6 +19,12 @@ */ public abstract class AbstractHttpClient implements HttpClient { + private final Vertx vertx; + + public AbstractHttpClient(Vertx vertx) { + this.vertx = vertx; + } + protected abstract HttpClientRequest doRequest(HttpMethod method, String uri); public HttpClientRequest options(String uri) { @@ -71,7 +80,7 @@ public Future request(RequestOptions requestOptions) { @Override public void request(HttpMethod httpMethod, int i, String s, String s1, Handler> handler) { - Future.succeededFuture(doRequest(httpMethod, s1)).onComplete(handler); + vertx.runOnContext(v -> succeededFuture(doRequest(httpMethod, s1)).onComplete(handler)); } @Override @@ -90,7 +99,7 @@ public Future request(HttpMethod httpMethod, String s, String @Override public void request(HttpMethod method, String requestURI, Handler> handler) { - throw new UnsupportedOperationException(); + vertx.runOnContext(v -> succeededFuture(doRequest(method, requestURI)).onComplete(handler)); } @Override diff --git a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClient.java b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClient.java index 1750f7d6..07848ea7 100644 --- a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClient.java +++ b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClient.java @@ -15,6 +15,7 @@ public class LocalHttpClient extends AbstractHttpClient { private Vertx vertx; public LocalHttpClient(Vertx vertx) { + super(vertx); this.vertx = vertx; }