From d3422103dd4c8a89a09e99912f7fcd57ddfa1fa3 Mon Sep 17 00:00:00 2001 From: luneo7 Date: Fri, 31 Mar 2023 15:38:27 -0500 Subject: [PATCH] Revert io.netty.noUnsafe change --- .../quarkus/netty/deployment/NettyProcessor.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java b/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java index c4280b43adc6b..76174e603d396 100644 --- a/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java +++ b/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java @@ -31,7 +31,6 @@ import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.UnsafeAccessedFieldBuildItem; import io.quarkus.deployment.logging.LogCleanupFilterBuildItem; -import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.netty.BossEventLoopGroup; import io.quarkus.netty.MainEventLoopGroup; import io.quarkus.netty.runtime.EmptyByteBufStub; @@ -78,11 +77,10 @@ public SystemPropertyBuildItem setNettyMachineId() { return new SystemPropertyBuildItem("io.netty.machineId", nettyMachineId); } - @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + @BuildStep NativeImageConfigBuildItem build( NettyBuildTimeConfig config, BuildProducer reflectiveClass, - BuildProducer systemProperties, List minMaxOrderBuildItems) { reflectiveClass.produce(ReflectiveClassBuildItem.builder("io.netty.channel.socket.nio.NioSocketChannel") @@ -99,8 +97,6 @@ NativeImageConfigBuildItem build( String maxOrder = calculateMaxOrder(config.allocatorMaxOrder, minMaxOrderBuildItems, false); NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder() - // disable unsafe usage to allow io.netty.internal.PlarformDependent0 to be reinitialized without issues - .addNativeImageSystemProperty("io.netty.noUnsafe", "true") // Use small chunks to avoid a lot of wasted space. Default is 16mb * arenas (derived from core count) // Since buffers are cached to threads, the malloc overhead is temporary anyway .addNativeImageSystemProperty("io.netty.allocator.maxOrder", maxOrder) @@ -116,14 +112,8 @@ NativeImageConfigBuildItem build( .addRuntimeInitializedClass("io.netty.buffer.ByteBufUtil") // The default channel id uses the process id, it should not be cached in the native image. .addRuntimeInitializedClass("io.netty.channel.DefaultChannelId") - // Make sure to re-initialize platform dependent classes/values at runtime - .addRuntimeReinitializedClass("io.netty.util.internal.PlatformDependent") - .addRuntimeReinitializedClass("io.netty.util.internal.PlatformDependent0") .addNativeImageSystemProperty("io.netty.leakDetection.level", "DISABLED"); - // Also set io.netty.noUnsafe at runtime - systemProperties.produce(new SystemPropertyBuildItem("io.netty.noUnsafe", "true")); - if (QuarkusClassLoader.isClassPresentAtRuntime("io.netty.handler.codec.http.HttpObjectEncoder")) { builder .addRuntimeInitializedClass("io.netty.handler.codec.http.HttpObjectEncoder") @@ -172,7 +162,8 @@ NativeImageConfigBuildItem build( log.debug("Not registering Netty native kqueue classes as they were not found"); } - return builder.build(); + return builder //TODO: make configurable + .build(); } @BuildStep