Skip to content

Commit

Permalink
Also set io.netty.noUnsafe at runtime when set at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Feb 22, 2023
1 parent 181dae5 commit 2d3702f
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
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;
Expand Down Expand Up @@ -77,10 +78,11 @@ public SystemPropertyBuildItem setNettyMachineId() {
return new SystemPropertyBuildItem("io.netty.machineId", nettyMachineId);
}

@BuildStep
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
NativeImageConfigBuildItem build(
NettyBuildTimeConfig config,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<SystemPropertyBuildItem> systemProperties,
List<MinNettyAllocatorMaxOrderBuildItem> minMaxOrderBuildItems) {

reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, "io.netty.channel.socket.nio.NioSocketChannel"));
Expand Down Expand Up @@ -115,6 +117,9 @@ NativeImageConfigBuildItem build(
.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")
Expand Down Expand Up @@ -163,8 +168,7 @@ NativeImageConfigBuildItem build(
log.debug("Not registering Netty native kqueue classes as they were not found");
}

return builder //TODO: make configurable
.build();
return builder.build();
}

@BuildStep
Expand Down

0 comments on commit 2d3702f

Please sign in to comment.