Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,6 @@ NativeImageConfigBuildItem build(
.build();
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void eagerlyInitClass(NettyRecorder recorder) {
//see https://github.com/quarkusio/quarkus/issues/3663
//this class is slow to initialize, we make sure that we do it eagerly
//before it blocks the IO thread and causes a warning
recorder.eagerlyInitChannelId();
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,13 @@

import java.util.function.Supplier;

import org.jboss.logging.Logger;

import io.netty.channel.DefaultChannelId;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.quarkus.runtime.annotations.Recorder;

@Recorder
public class NettyRecorder {

private static final Logger log = Logger.getLogger(NettyRecorder.class);

// TODO: Remove this method (maybe in 1.6.x of Quarkus or later) if there are no user reports
// of the WARN message issued from this method. See comments in https://github.com/quarkusio/quarkus/pull/9246
// for details
public void eagerlyInitChannelId() {
//this class is slow to init and can block the IO thread and cause a warning
//we init it from a throwaway thread to stop this
//we do it from another thread so as not to affect start time
new Thread(new Runnable() {
@Override
public void run() {
long start = System.currentTimeMillis();
DefaultChannelId.newInstance();
if (System.currentTimeMillis() - start > 1000) {
log.warn("Netty DefaultChannelId initialization (with io.netty.machineId" +
" system property set to " + System.getProperty("io.netty.machineId")
+ ") took more than a second");
}
}
}).start();
}

public Supplier<EventLoopGroup> createEventLoop(int nThreads) {
return new Supplier<EventLoopGroup>() {

Expand Down
Loading