Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to Vert.x 4.3.1 and Netty 4.1.78 #26294

Merged
merged 2 commits into from Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions bom/application/pom.xml
Expand Up @@ -109,7 +109,8 @@
<wildfly-client-config.version>1.0.1.Final</wildfly-client-config.version>
<wildfly-elytron.version>1.19.0.Final</wildfly-elytron.version>
<jboss-threads.version>3.4.2.Final</jboss-threads.version>
<vertx.version>4.2.7</vertx.version>
<vertx.version>4.3.1</vertx.version>

<httpclient.version>4.5.13</httpclient.version>
<httpcore.version>4.4.15</httpcore.version>
<httpasync.version>4.1.5</httpasync.version>
Expand All @@ -132,7 +133,8 @@
<infinispan.version>13.0.10.Final</infinispan.version>
<infinispan.protostream.version>4.4.3.Final</infinispan.protostream.version>
<caffeine.version>2.9.3</caffeine.version>
<netty.version>4.1.74.Final</netty.version>
<netty.version>4.1.78.Final</netty.version>
<brotli4j.version>1.7.1</brotli4j.version>
<reactive-streams.version>1.0.3</reactive-streams.version>
<jboss-logging.version>3.5.0.Final</jboss-logging.version>
<mutiny.version>1.6.0</mutiny.version>
Expand Down Expand Up @@ -240,6 +242,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.aayushatharva.brotli4j</groupId>
<artifactId>brotli4j</artifactId>
<version>${brotli4j.version}</version>
</dependency>

<!-- Jackson dependencies, imported as a BOM -->
<dependency>
Expand Down
Expand Up @@ -210,6 +210,8 @@ httpMethod, ofNullable(request.getRawQueryString())

HttpContent requestContent = LastHttpContent.EMPTY_LAST_CONTENT;
if (request.getBody() != null) {
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
nettyRequest.headers().add(HttpHeaderNames.TRANSFER_ENCODING, "chunked");
if (request.getIsBase64Encoded()) {
ByteBuf body = Unpooled.wrappedBuffer(Base64.getDecoder().decode(request.getBody()));
requestContent = new DefaultLastHttpContent(body);
Expand Down
Expand Up @@ -197,6 +197,8 @@ private AwsProxyResponse nettyDispatch(InetSocketAddress clientAddress, AwsProxy

HttpContent requestContent = LastHttpContent.EMPTY_LAST_CONTENT;
if (request.getBody() != null) {
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
nettyRequest.headers().add(HttpHeaderNames.TRANSFER_ENCODING, "chunked");
if (request.isBase64Encoded()) {
ByteBuf body = Unpooled.wrappedBuffer(Base64.getDecoder().decode(request.getBody()));
requestContent = new DefaultLastHttpContent(body);
Expand Down
Expand Up @@ -112,7 +112,9 @@ NativeImageConfigBuildItem build(
builder
.addRuntimeInitializedClass("io.netty.handler.codec.http.HttpObjectEncoder")
.addRuntimeInitializedClass("io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder")
.addRuntimeInitializedClass("io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder");
.addRuntimeInitializedClass("io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder")
.addRuntimeInitializedClass("io.netty.handler.codec.compression.ZstdOptions")
.addRuntimeInitializedClass("io.netty.handler.codec.compression.BrotliOptions");
} else {
log.debug("Not registering Netty HTTP classes as they were not found");
}
Expand Down
10 changes: 10 additions & 0 deletions extensions/netty/runtime/pom.xml
Expand Up @@ -61,6 +61,16 @@
<classifier>osx-x86_64</classifier>
<optional>true</optional>
</dependency>

<!--
The recent version of Netty have a hard dependency on brotli,
without this dependency, it's not possible to compile to native
-->
<dependency>
<groupId>com.aayushatharva.brotli4j</groupId>
<artifactId>brotli4j</artifactId>
<version>1.7.1</version> <!-- TODO Extract this version -->
</dependency>
</dependencies>

<build>
Expand Down
@@ -1,22 +1,12 @@
package io.quarkus.netty.runtime.graal;

import static io.netty.handler.codec.http.HttpHeaderValues.DEFLATE;
import static io.netty.handler.codec.http.HttpHeaderValues.GZIP;
import static io.netty.handler.codec.http.HttpHeaderValues.X_DEFLATE;
import static io.netty.handler.codec.http.HttpHeaderValues.X_GZIP;

import java.util.function.BooleanSupplier;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.codec.compression.ZlibWrapper;
import io.netty.handler.codec.http2.CompressorHttp2ConnectionEncoder;
import io.netty.handler.codec.http2.Http2Exception;

public class HttpContentCompressorSubstitutions {

Expand All @@ -39,42 +29,6 @@ public void flush(final ChannelHandlerContext ctx) {
}
}

@TargetClass(className = "io.netty.handler.codec.compression.BrotliEncoder", onlyWith = IsBrotliAbsent.class)
public static final class BrEncoderFactorySubstitution {

@Substitute
protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception {
throw new UnsupportedOperationException();
}

@Substitute
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) {
throw new UnsupportedOperationException();
}
}

@TargetClass(CompressorHttp2ConnectionEncoder.class)
public static final class CompressorHttp2ConnectionSubstitute {

@Substitute
protected EmbeddedChannel newContentCompressor(ChannelHandlerContext ctx, CharSequence contentEncoding)
throws Http2Exception {
if (GZIP.contentEqualsIgnoreCase(contentEncoding) || X_GZIP.contentEqualsIgnoreCase(contentEncoding)) {
return newCompressionChannel(ctx, ZlibWrapper.GZIP);
}
if (DEFLATE.contentEqualsIgnoreCase(contentEncoding) || X_DEFLATE.contentEqualsIgnoreCase(contentEncoding)) {
return newCompressionChannel(ctx, ZlibWrapper.ZLIB);
}
// 'identity' or unsupported
return null;
}

@Alias
private EmbeddedChannel newCompressionChannel(final ChannelHandlerContext ctx, ZlibWrapper wrapper) {
throw new UnsupportedOperationException();
}
}

public static class IsZstdAbsent implements BooleanSupplier {

private boolean zstdAbsent;
Expand All @@ -93,23 +47,4 @@ public boolean getAsBoolean() {
return zstdAbsent;
}
}

public static class IsBrotliAbsent implements BooleanSupplier {

private boolean brotliAbsent;

public IsBrotliAbsent() {
try {
Class.forName("com.aayushatharva.brotli4j.encoder.Encoder");
brotliAbsent = false;
} catch (ClassNotFoundException e) {
brotliAbsent = true;
}
}

@Override
public boolean getAsBoolean() {
return brotliAbsent;
}
}
}
Expand Up @@ -403,8 +403,8 @@ final class Holder_io_netty_util_concurrent_ScheduledFutureTask {
static final long START_TIME = System.nanoTime();
}

@TargetClass(className = "io.netty.util.concurrent.ScheduledFutureTask")
final class Target_io_netty_util_concurrent_ScheduledFutureTask {
@TargetClass(className = "io.netty.util.concurrent.AbstractScheduledEventExecutor")
final class Target_io_netty_util_concurrent_AbstractScheduledEventExecutor {

// The START_TIME field is kept but not used.
// All the accesses to it have been replaced with Holder_io_netty_util_concurrent_ScheduledFutureTask
Expand All @@ -415,20 +415,9 @@ static long initialNanoTime() {
}

@Substitute
static long nanoTime() {
static long defaultCurrentTimeNanos() {
return System.nanoTime() - Holder_io_netty_util_concurrent_ScheduledFutureTask.START_TIME;
}

@Alias
public long deadlineNanos() {
return 0;
}

@Substitute
public long delayNanos(long currentTimeNanos) {
return Math.max(0,
deadlineNanos() - (currentTimeNanos - Holder_io_netty_util_concurrent_ScheduledFutureTask.START_TIME));
}
}

@TargetClass(className = "io.netty.channel.ChannelHandlerMask")
Expand Down Expand Up @@ -496,16 +485,6 @@ public long memoryAddress() {

}

// We need to delete this class, but we let GraalVM dead code elimination do it for us.
// Otherwise, it causes a problem when --report-unsupported-elements-at-runtime is enabled:
// when trying to delete the class, GraalVM throws a java.lang.NoClassDefFoundError: Lcom/aayushatharva/brotli4j/decoder/DecoderJNI$Wrapper;
// While we recommend not using this option, some extensions out there are using it.
//@TargetClass(className = "io.netty.handler.codec.compression.BrotliDecoder")
//@Delete
//final class Target_BrotliDecoder {
//
//}

@TargetClass(className = "io.netty.handler.codec.http.HttpContentDecompressor")
final class Target_io_netty_handler_codec_http_HttpContentDecompressor {

Expand Down Expand Up @@ -561,6 +540,15 @@ protected EmbeddedChannel newContentDecompressor(ChannelHandlerContext ctx, Char
}
}

@TargetClass(className = "io.netty.handler.ssl.SslHandler")
final class Target_SslHandler {

@Substitute
private void setOpensslEngineSocketFd(Channel c) {
// do nothing.
}
}

class NettySubstitutions {

}
Expand Up @@ -225,4 +225,4 @@ static List<String> get() {

class VertxSubstitutions {

}
}
2 changes: 1 addition & 1 deletion independent-projects/resteasy-reactive/pom.xml
Expand Up @@ -56,7 +56,7 @@
<jakarta.json.version>1.1.6</jakarta.json.version>
<mutiny.version>1.6.0</mutiny.version>
<smallrye-common.version>1.12.0</smallrye-common.version>
<vertx.version>4.2.4</vertx.version>
<vertx.version>4.3.1</vertx.version>
<rest-assured.version>4.5.1</rest-assured.version>
<commons-logging-jboss-logging.version>1.0.0.Final</commons-logging-jboss-logging.version>
<jboss-jaxb-api_2.3_spec.version>2.0.0.Final</jboss-jaxb-api_2.3_spec.version>
Expand Down
Expand Up @@ -71,5 +71,9 @@ public void setQueryParameters(Map<String, String> queryParameters) {

public void setBody(String body) {
this.body = body;
if (body != null) {
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
getHeaders().put("Content-Length", Integer.toString(body.length()));
}
}
}