Skip to content

Commit

Permalink
Bump to Vert.x 4.3.1 and Netty 4.1.78
Browse files Browse the repository at this point in the history
This new combination is tricky. It imposes to have brotli4j available in the classpath as, because of the new HTTP compression feature from vert.x, it does now have a hard dependency on brotli4j. While in JVM mode, everything is fine, native compilation fails if not there. We have tried a few things to avoid the dependency, but we are hitting oracle/graal#4652.
  • Loading branch information
cescoffier committed Jun 22, 2022
1 parent 3b143a4 commit dd351e1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 94 deletions.
11 changes: 9 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,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 @@ -130,7 +131,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 @@ -237,6 +239,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
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ 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");
} 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
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 {

}
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,4 @@ static List<String> get() {

class VertxSubstitutions {

}
}
2 changes: 1 addition & 1 deletion independent-projects/resteasy-reactive/pom.xml
Original file line number Diff line number Diff line change
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

0 comments on commit dd351e1

Please sign in to comment.