Skip to content

Commit

Permalink
Update to Vert.x 4.4.5 and Netty 4.1.97.Final
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier committed Aug 31, 2023
1 parent 176c5bc commit 9178364
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 88 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<wildfly-client-config.version>1.0.1.Final</wildfly-client-config.version>
<wildfly-elytron.version>2.2.2.Final</wildfly-elytron.version>
<jboss-threads.version>3.5.0.Final</jboss-threads.version>
<vertx.version>4.4.4</vertx.version>
<vertx.version>4.4.5</vertx.version>
<httpclient.version>4.5.14</httpclient.version>
<httpcore.version>4.4.16</httpcore.version>
<httpasync.version>4.1.5</httpasync.version>
Expand All @@ -142,7 +142,7 @@
<infinispan.version>14.0.14.Final</infinispan.version>
<infinispan.protostream.version>4.6.2.Final</infinispan.protostream.version>
<caffeine.version>3.1.5</caffeine.version>
<netty.version>4.1.94.Final</netty.version>
<netty.version>4.1.97.Final</netty.version>
<brotli4j.version>1.12.0</brotli4j.version>
<reactive-streams.version>1.0.4</reactive-streams.version>
<jboss-logging.version>3.5.3.Final</jboss-logging.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,16 @@ public CompletionStage<Void> executeBlockingIo(RunnableWithException f, boolean
suspend();
}
CompletableFuture<Void> ret = new CompletableFuture<>();
this.request.context.executeBlocking(future -> {
try (CloseableContext newContext = ResteasyContext.addCloseableContextDataLevel(context)) {
this.request.context.<Void> executeBlocking(() -> {
try (CloseableContext ignored = ResteasyContext.addCloseableContextDataLevel(context)) {
f.run();
future.complete();
return null;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, res -> {
}).onComplete(res -> {
if (res.succeeded())
ret.complete(null);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ public static ResteasyUriInfo extractUriInfo(HttpServerRequest req, String conte
if (uri.startsWith(protocol + "://")) {
uriString = uri;
} else {
String host = req.host();
if (host == null) {
host = "unknown";
var authority = req.authority();
if (authority == null) {
uriString = protocol + "//unknown" + uri;
} else {
uriString = protocol + "://" + authority.host() + ":" + authority.port() + uri;
}
uriString = protocol + "://" + host + uri;
}

// ResteasyUriInfo expects a context path to start with a "/" character
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public String getRequestScheme() {

@Override
public String getRequestHost() {
return context.request().host();
return context.request().authority().toString();
}

@Override
Expand All @@ -246,7 +246,7 @@ public void closeConnection() {
} catch (IOException e) {
//ignore
}
context.response().close();
context.request().connection().close();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ private Task(Context context, Runnable runnable, boolean blocking) {

void run() {
if (blocking) {
context.executeBlocking(p -> {
context.executeBlocking(() -> {
runnable.run();
p.complete();
return null;
});
} else {
context.runOnContext(x -> runnable.run());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Uni<ChallengeData> getChallenge(RoutingContext context) {
}

static Uni<ChallengeData> getRedirect(final RoutingContext exchange, final String location) {
String loc = exchange.request().scheme() + "://" + exchange.request().host() + location;
String loc = exchange.request().scheme() + "://" + exchange.request().authority().toString() + location;
return Uni.createFrom().item(new ChallengeData(302, "Location", loc));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ public static boolean nonBlockingShouldExecuteBlocking(Operation operation, Cont
@SuppressWarnings("unchecked")
public static void runBlocking(Context vc, Callable<Object> contextualCallable, Promise result) {
// Here call blocking with context
vc.executeBlocking(future -> {
try {
future.complete(contextualCallable.call());
} catch (Exception ex) {
future.fail(ex);
}
}, result);
vc.executeBlocking(contextualCallable).onComplete(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void calculate() {
calculated = true;
remoteAddress = delegate.remoteAddress();
scheme = delegate.scheme();
setHostAndPort(delegate.host(), port);
setHostAndPort(delegate.getHeader(HttpHeaders.HOST), port);
uri = delegate.uri();

if (trustedProxyCheck.isProxyAllowed()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private LocalServerNameAttribute() {

@Override
public String readAttribute(final RoutingContext exchange) {
return exchange.request().host();
return exchange.request().authority().toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.LogManager;
Expand All @@ -21,7 +22,6 @@
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.net.impl.ConnectionBase;
import io.vertx.ext.web.RoutingContext;
Expand Down Expand Up @@ -98,29 +98,26 @@ public void handle(AsyncResult<Void> event) {
routingContext.request().endHandler(new Handler<Void>() {
@Override
public void handle(Void event) {
VertxCoreRecorder.getVertx().get().getOrCreateContext().executeBlocking(new Handler<Promise<Object>>() {
VertxCoreRecorder.getVertx().get().getOrCreateContext().executeBlocking(new Callable<Void>() {
@Override
public void handle(Promise<Object> promise) {
try {
String redirect = "/";
MultiMap attrs = routingContext.request().formAttributes();
Map<String, String> newVals = new HashMap<>();
for (Map.Entry<String, String> i : attrs) {
if (i.getKey().startsWith("key.")) {
newVals.put(i.getKey().substring("key.".length()), i.getValue());
} else if (i.getKey().equals("redirect")) {
redirect = i.getValue();
}
public Void call() {
String redirect = "/";
MultiMap attrs = routingContext.request().formAttributes();
Map<String, String> newVals = new HashMap<>();
for (Map.Entry<String, String> i : attrs) {
if (i.getKey().startsWith("key.")) {
newVals.put(i.getKey().substring("key.".length()), i.getValue());
} else if (i.getKey().equals("redirect")) {
redirect = i.getValue();
}
CurrentConfig.EDITOR.accept(newVals);
routingContext.response().setStatusCode(HttpResponseStatus.SEE_OTHER.code()).headers()
.set(HttpHeaderNames.LOCATION, redirect);
routingContext.response().end();
} catch (Throwable t) {
routingContext.fail(t);
}
CurrentConfig.EDITOR.accept(newVals);
routingContext.response().setStatusCode(HttpResponseStatus.SEE_OTHER.code()).headers()
.set(HttpHeaderNames.LOCATION, redirect);
routingContext.response().end();
return null;
}
});
}).onFailure(routingContext::fail);
}
});
routingContext.request().resume();
Expand All @@ -136,9 +133,9 @@ public void handle(Promise<Object> promise) {
return;
}
ClassLoader current = Thread.currentThread().getContextClassLoader();
VertxCoreRecorder.getVertx().get().getOrCreateContext().executeBlocking(new Handler<Promise<Boolean>>() {
VertxCoreRecorder.getVertx().get().getOrCreateContext().executeBlocking(new Callable<Boolean>() {
@Override
public void handle(Promise<Boolean> event) {
public Boolean call() throws Exception {
//the blocking pool may have a stale TCCL
Thread.currentThread().setContextClassLoader(current);
boolean restart = false;
Expand All @@ -151,8 +148,7 @@ public void handle(Promise<Boolean> event) {
try {
restart = hotReplacementContext.doScan(true);
} catch (Exception e) {
event.fail(new IllegalStateException("Unable to perform live reload scanning", e));
return;
throw new IllegalStateException("Unable to perform live reload scanning", e);
}
if (currentState != VertxHttpRecorder.getCurrentApplicationState()) {
//its possible a Kafka message or some other source triggered a reload,
Expand All @@ -163,8 +159,11 @@ public void handle(Promise<Boolean> event) {
}
}
if (hotReplacementContext.getDeploymentProblem() != null) {
event.fail(hotReplacementContext.getDeploymentProblem());
return;
if (hotReplacementContext.getDeploymentProblem() instanceof Exception) {
throw (Exception) hotReplacementContext.getDeploymentProblem();
} else {
throw new IllegalStateException(hotReplacementContext.getDeploymentProblem());
}
}
if (restart) {
//close all connections on close, except for this one
Expand All @@ -180,24 +179,25 @@ public void handle(Promise<Boolean> event) {
} finally {
DevConsoleManager.setDoingHttpInitiatedReload(false);
}
event.complete(restart);
return restart;
}
}, false, new Handler<AsyncResult<Boolean>>() {
@Override
public void handle(AsyncResult<Boolean> event) {
if (event.failed()) {
handleDeploymentProblem(routingContext, event.cause());
} else {
boolean restart = event.result();
if (restart) {
routingContext.request().headers().set(HEADER_NAME, "true");
VertxHttpRecorder.getRootHandler().handle(routingContext.request());
} else {
routingContext.next();
}, false)
.onComplete(new Handler<AsyncResult<Boolean>>() {
@Override
public void handle(AsyncResult<Boolean> event) {
if (event.failed()) {
handleDeploymentProblem(routingContext, event.cause());
} else {
boolean restart = event.result();
if (restart) {
routingContext.request().headers().set(HEADER_NAME, "true");
VertxHttpRecorder.getRootHandler().handle(routingContext.request());
} else {
routingContext.next();
}
}
}
}
}
});
});

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.http.StreamPriority;
import io.vertx.core.net.HostAndPort;
import io.vertx.core.streams.ReadStream;

class AbstractResponseWrapper implements HttpServerResponse {
Expand Down Expand Up @@ -323,6 +324,7 @@ public HttpServerResponse sendFile(String filename, long offset, long length,
}

@Override
@Deprecated
public void close() {
delegate.close();
}
Expand Down Expand Up @@ -376,7 +378,7 @@ public HttpServerResponse push(HttpMethod method, String host, String path,

@Override
public Future<HttpServerResponse> push(HttpMethod method, String host, String path) {
return null;
return delegate.push(method, host, path);
}

@Override
Expand All @@ -389,7 +391,7 @@ public HttpServerResponse push(HttpMethod method, String path, MultiMap headers,

@Override
public Future<HttpServerResponse> push(HttpMethod method, String path, MultiMap headers) {
return null;
return delegate.push(method, path, headers);
}

@Override
Expand All @@ -401,7 +403,7 @@ public HttpServerResponse push(HttpMethod method, String path, Handler<AsyncResu

@Override
public Future<HttpServerResponse> push(HttpMethod method, String path) {
return null;
return delegate.push(method, path);
}

@Override
Expand All @@ -414,7 +416,12 @@ public HttpServerResponse push(HttpMethod method, String host, String path, Mult

@Override
public Future<HttpServerResponse> push(HttpMethod method, String host, String path, MultiMap headers) {
return null;
return delegate.push(method, host, path, headers);
}

@Override
public Future<HttpServerResponse> push(HttpMethod method, HostAndPort authority, String path, MultiMap headers) {
return delegate.push(method, authority, path, headers);
}

@Override
Expand Down Expand Up @@ -495,4 +502,5 @@ public void end(Handler<AsyncResult<Void>> handler) {
public boolean writeQueueFull() {
return delegate.writeQueueFull();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected void handleRedirectBack(final RoutingContext exchange) {
throw new IllegalStateException(
"Landing page is no set, please make sure 'quarkus.http.auth.form.landing-page' is configured properly.");
}
location = exchange.request().scheme() + "://" + exchange.request().host() + landingPage;
location = exchange.request().scheme() + "://" + exchange.request().authority().toString() + landingPage;
}
exchange.response().setStatusCode(302);
exchange.response().headers().add(HttpHeaderNames.LOCATION, location);
Expand Down Expand Up @@ -173,14 +173,14 @@ protected void servePage(final RoutingContext exchange, final String location) {
}

static void sendRedirect(final RoutingContext exchange, final String location) {
String loc = exchange.request().scheme() + "://" + exchange.request().host() + location;
String loc = exchange.request().scheme() + "://" + exchange.request().authority().toString() + location;
exchange.response().headers().add(HttpHeaderNames.LOCATION, loc);
exchange.response().setStatusCode(302);
exchange.response().end();
}

static Uni<ChallengeData> getRedirect(final RoutingContext exchange, final String location) {
String loc = exchange.request().scheme() + "://" + exchange.request().host() + location;
String loc = exchange.request().scheme() + "://" + exchange.request().authority().toString() + location;
return Uni.createFrom().item(new ChallengeData(302, "Location", loc));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.setContextSafe;
import static io.smallrye.common.vertx.VertxContext.getOrCreateDuplicatedContext;

import java.util.concurrent.Callable;
import java.util.function.Supplier;

import jakarta.inject.Inject;
Expand All @@ -11,8 +12,6 @@
import io.quarkus.security.spi.runtime.BlockingSecurityExecutor;
import io.smallrye.mutiny.Uni;
import io.vertx.core.Context;
import io.vertx.core.Handler;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;

public class VertxBlockingSecurityExecutor implements BlockingSecurityExecutor {
Expand All @@ -38,14 +37,10 @@ public Uni<? extends T> get() {
.createFrom()
.completionStage(
local
.executeBlocking(new Handler<Promise<T>>() {
.executeBlocking(new Callable<T>() {
@Override
public void handle(Promise<T> promise) {
try {
promise.complete(supplier.get());
} catch (Throwable t) {
promise.fail(t);
}
public T call() {
return supplier.get();
}
})
.toCompletionStage());
Expand Down
Loading

0 comments on commit 9178364

Please sign in to comment.