Skip to content

Commit

Permalink
Merge pull request quarkusio#40249 from zakkak/2024-04-24-fix-40243-v2
Browse files Browse the repository at this point in the history
Move reinitialization of vertx classes out of NettyProcessor
  • Loading branch information
gastaldi authored Apr 24, 2024
2 parents e7ede18 + c610a8b commit e2b7ae7
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 e2b7ae7

Please sign in to comment.