Skip to content

Commit 18feffa

Browse files
jbzhurslandelle
authored andcommitted
Set timer thread name as threadPoolName + "-timer"..., if timer is not provided in config (AsyncHttpClient#1504)
1 parent 5100e04 commit 18feffa

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClient.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.netty.handler.codec.http.cookie.Cookie;
2121
import io.netty.util.HashedWheelTimer;
2222
import io.netty.util.Timer;
23+
import io.netty.util.concurrent.DefaultThreadFactory;
2324
import org.asynchttpclient.channel.ChannelPool;
2425
import org.asynchttpclient.filter.FilterContext;
2526
import org.asynchttpclient.filter.FilterException;
@@ -31,6 +32,7 @@
3132
import org.slf4j.LoggerFactory;
3233

3334
import java.util.List;
35+
import java.util.concurrent.ThreadFactory;
3436
import java.util.concurrent.atomic.AtomicBoolean;
3537
import java.util.function.Predicate;
3638

@@ -82,15 +84,16 @@ public DefaultAsyncHttpClient(AsyncHttpClientConfig config) {
8284
this.config = config;
8385
this.noRequestFilters = config.getRequestFilters().isEmpty();
8486
allowStopNettyTimer = config.getNettyTimer() == null;
85-
nettyTimer = allowStopNettyTimer ? newNettyTimer() : config.getNettyTimer();
87+
nettyTimer = allowStopNettyTimer ? newNettyTimer(config) : config.getNettyTimer();
8688

8789
channelManager = new ChannelManager(config, nettyTimer);
8890
requestSender = new NettyRequestSender(config, channelManager, nettyTimer, new AsyncHttpClientState(closed));
8991
channelManager.configureBootstraps(requestSender);
9092
}
9193

92-
private Timer newNettyTimer() {
93-
HashedWheelTimer timer = new HashedWheelTimer();
94+
private Timer newNettyTimer(AsyncHttpClientConfig config) {
95+
ThreadFactory threadFactory = new DefaultThreadFactory(config.getThreadPoolName() + "-timer");
96+
HashedWheelTimer timer = new HashedWheelTimer(threadFactory);
9497
timer.start();
9598
return timer;
9699
}

0 commit comments

Comments
 (0)