Skip to content

Commit

Permalink
Merge pull request #32319 from luneo7/revert-unsafe-2.16
Browse files Browse the repository at this point in the history
[2.16] Revert io.netty.noUnsafe change
  • Loading branch information
gsmet authored Apr 2, 2023
2 parents 34accfc + 54a4d81 commit d037b44
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,7 +77,7 @@ public SystemPropertyBuildItem setNettyMachineId() {
return new SystemPropertyBuildItem("io.netty.machineId", nettyMachineId);
}

@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
@BuildStep
NativeImageConfigBuildItem build(
NettyBuildTimeConfig config,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
Expand All @@ -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)
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d037b44

Please sign in to comment.