From 54a4d81e70c261bd7abf82e2893f5bd7be5577d7 Mon Sep 17 00:00:00 2001 From: luneo7 Date: Fri, 31 Mar 2023 15:50:50 -0500 Subject: [PATCH] Revert io.netty.noUnsafe change --- .../quarkus/netty/deployment/NettyProcessor.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 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 13171bec79646..365f1ac191f73 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,7 +77,7 @@ public SystemPropertyBuildItem setNettyMachineId() { return new SystemPropertyBuildItem("io.netty.machineId", nettyMachineId); } - @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + @BuildStep NativeImageConfigBuildItem build( NettyBuildTimeConfig config, BuildProducer reflectiveClass, @@ -95,8 +94,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) @@ -112,14 +109,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") @@ -168,7 +159,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