From d41c78bf553406c6026d28ff2795f096b9da184d Mon Sep 17 00:00:00 2001 From: Clement Escoffier Date: Mon, 4 Sep 2023 08:34:30 +0200 Subject: [PATCH] Update to Vert.x 4.4.5 and Netty 4.1.97 Also bump Quarkus HTTP to 5.0.3.Final to handle a breaking change in the Vert.x API. Fix #35180 Fix #34719 Fix #35278 --- bom/application/pom.xml | 6 +++--- .../resteasy/runtime/standalone/VertxUtil.java | 9 +++++---- .../vertx/http/runtime/ForwardedParser.java | 14 +++++++++++++- .../runtime/ForwardedServerRequestWrapper.java | 6 ++++++ .../runtime/filters/AbstractResponseWrapper.java | 16 ++++++++++++---- independent-projects/resteasy-reactive/pom.xml | 2 +- 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 45bc122623fee..369fd4a160939 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -34,7 +34,7 @@ 1.28.0 1.28.0-alpha 1.8.1 - 5.0.2.Final + 5.0.3.Final 1.11.1 2.1.12 0.22.0 @@ -120,7 +120,7 @@ 1.0.1.Final 2.2.2.Final 3.5.0.Final - 4.4.4 + 4.4.5 4.5.14 4.4.16 4.1.5 @@ -142,7 +142,7 @@ 14.0.14.Final 4.6.2.Final 3.1.5 - 4.1.94.Final + 4.1.97.Final 1.12.0 1.0.4 3.5.3.Final diff --git a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxUtil.java b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxUtil.java index bf0d8f73944ba..855f2e7f73f91 100644 --- a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxUtil.java +++ b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxUtil.java @@ -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 + uri; } - uriString = protocol + "://" + host + uri; } // ResteasyUriInfo expects a context path to start with a "/" character diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java index 09ec83ecdab0f..6fe05d63185aa 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java @@ -27,6 +27,7 @@ import io.netty.util.AsciiString; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.net.HostAndPort; import io.vertx.core.net.SocketAddress; import io.vertx.core.net.impl.SocketAddressImpl; @@ -60,6 +61,8 @@ class ForwardedParser { private String absoluteURI; private SocketAddress remoteAddress; + private HostAndPort authority; + ForwardedParser(HttpServerRequest delegate, ForwardingProxyOptions forwardingProxyOptions, TrustedProxyCheck trustedProxyCheck) { this.delegate = delegate; @@ -86,6 +89,13 @@ boolean isSSL() { return scheme.equals(HTTPS_SCHEME); } + HostAndPort authority() { + if (!calculated) { + calculate(); + } + return authority; + } + String absoluteURI() { if (!calculated) calculate(); @@ -111,7 +121,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()) { @@ -176,6 +186,7 @@ private void calculate() { port = -1; } + authority = HostAndPort.create(host, port >= 0 ? port : -1); host = host + (port >= 0 ? ":" + port : ""); delegate.headers().set(HttpHeaders.HOST, host); absoluteURI = scheme + "://" + host + uri; @@ -267,4 +278,5 @@ private String stripSlashes(String uri) { return result; } + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedServerRequestWrapper.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedServerRequestWrapper.java index d4da4d5c7f44d..9db2c98f15902 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedServerRequestWrapper.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedServerRequestWrapper.java @@ -26,6 +26,7 @@ import io.vertx.core.http.StreamPriority; import io.vertx.core.http.impl.HttpServerRequestInternal; import io.vertx.core.http.impl.HttpServerRequestWrapper; +import io.vertx.core.net.HostAndPort; import io.vertx.core.net.NetSocket; import io.vertx.core.net.SocketAddress; @@ -191,6 +192,11 @@ public SocketAddress remoteAddress() { return forwardedParser.remoteAddress(); } + @Override + public HostAndPort authority() { + return forwardedParser.authority(); + } + @Override public SocketAddress localAddress() { return delegate.localAddress(); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/filters/AbstractResponseWrapper.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/filters/AbstractResponseWrapper.java index 959af552f0dc7..7d87cbd15d2c1 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/filters/AbstractResponseWrapper.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/filters/AbstractResponseWrapper.java @@ -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 { @@ -323,6 +324,7 @@ public HttpServerResponse sendFile(String filename, long offset, long length, } @Override + @Deprecated public void close() { delegate.close(); } @@ -376,7 +378,7 @@ public HttpServerResponse push(HttpMethod method, String host, String path, @Override public Future push(HttpMethod method, String host, String path) { - return null; + return delegate.push(method, host, path); } @Override @@ -389,7 +391,7 @@ public HttpServerResponse push(HttpMethod method, String path, MultiMap headers, @Override public Future push(HttpMethod method, String path, MultiMap headers) { - return null; + return delegate.push(method, path, headers); } @Override @@ -401,7 +403,7 @@ public HttpServerResponse push(HttpMethod method, String path, Handler push(HttpMethod method, String path) { - return null; + return delegate.push(method, path); } @Override @@ -413,8 +415,14 @@ public HttpServerResponse push(HttpMethod method, String host, String path, Mult } @Override + @Deprecated public Future push(HttpMethod method, String host, String path, MultiMap headers) { - return null; + return delegate.push(method, host, path, headers); + } + + @Override + public Future push(HttpMethod method, HostAndPort authority, String path, MultiMap headers) { + return delegate.push(method, authority, path, headers); } @Override diff --git a/independent-projects/resteasy-reactive/pom.xml b/independent-projects/resteasy-reactive/pom.xml index a53964d90c45b..9c2f60090f8cf 100644 --- a/independent-projects/resteasy-reactive/pom.xml +++ b/independent-projects/resteasy-reactive/pom.xml @@ -64,7 +64,7 @@ 1.6.8 2.3.1 2.1.0 - 4.4.4 + 4.4.5 5.3.0 1.0.0.Final 2.15.2