Skip to content

Commit

Permalink
Move reinitialization of vertx classes out of NettyProcessor
Browse files Browse the repository at this point in the history
Vert.x is not a dependency of netty, meaning that the classes may not
always be on the classpath.

Fixes quarkusio#40243

Supersedes quarkusio#40248
  • Loading branch information
zakkak authored and poldinik committed Apr 29, 2024
1 parent 6809d7e commit b530de4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,8 @@ NativeImageConfigBuildItem build(
if (QuarkusClassLoader.isClassPresentAtRuntime("io.netty.buffer.UnpooledByteBufAllocator")) {
builder.addRuntimeReinitializedClass("io.netty.buffer.UnpooledByteBufAllocator")
.addRuntimeReinitializedClass("io.netty.buffer.Unpooled")
.addRuntimeReinitializedClass("io.vertx.core.http.impl.Http1xServerResponse")
.addRuntimeReinitializedClass("io.netty.handler.codec.http.HttpObjectAggregator")
.addRuntimeReinitializedClass("io.netty.handler.codec.ReplayingDecoderByteBuf")
.addRuntimeReinitializedClass("io.vertx.core.parsetools.impl.RecordParserImpl");

if (QuarkusClassLoader.isClassPresentAtRuntime("io.vertx.ext.web.client.impl.MultipartFormUpload")) {
builder.addRuntimeReinitializedClass("io.vertx.ext.web.client.impl.MultipartFormUpload");
}
.addRuntimeReinitializedClass("io.netty.handler.codec.ReplayingDecoderByteBuf");

if (QuarkusClassLoader
.isClassPresentAtRuntime("org.jboss.resteasy.reactive.client.impl.multipart.QuarkusMultipartFormUpload")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.quarkus.arc.processor.BeanInfo;
import io.quarkus.arc.processor.BuildExtension;
import io.quarkus.arc.processor.BuiltinScope;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Capability;
import io.quarkus.deployment.Feature;
Expand All @@ -44,6 +45,7 @@
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.ServiceStartBuildItem;
import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.gizmo.ClassOutput;
Expand Down Expand Up @@ -196,6 +198,23 @@ void faultToleranceIntegration(Capabilities capabilities, BuildProducer<ServiceP
}
}

/**
* Reinitialize vertx classes that are known to cause issues with Netty in native mode
*/
@BuildStep
NativeImageConfigBuildItem reinitializeClassesForNetty() {
NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder();

builder.addRuntimeReinitializedClass("io.vertx.core.http.impl.Http1xServerResponse")
.addRuntimeReinitializedClass("io.vertx.core.parsetools.impl.RecordParserImpl");

if (QuarkusClassLoader.isClassPresentAtRuntime("io.vertx.ext.web.client.impl.MultipartFormUpload")) {
builder.addRuntimeReinitializedClass("io.vertx.ext.web.client.impl.MultipartFormUpload");
}

return builder.build();
}

private Class<?> tryLoad(String name, ClassLoader tccl) {
try {
return tccl.loadClass(name);
Expand Down

0 comments on commit b530de4

Please sign in to comment.