Skip to content

Commit fe0fe2f

Browse files
authored
fixed NPE caused by open but unconnected channels. (AsyncHttpClient#1711)
1 parent 0b1b622 commit fe0fe2f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import java.net.InetSocketAddress;
6262
import java.util.Map;
6363
import java.util.Map.Entry;
64+
import java.util.Objects;
6465
import java.util.concurrent.ThreadFactory;
6566
import java.util.concurrent.TimeUnit;
6667
import java.util.function.Function;
@@ -490,7 +491,7 @@ public EventLoopGroup getEventLoopGroup() {
490491
}
491492

492493
public ClientStats getClientStats() {
493-
Map<String, Long> totalConnectionsPerHost = openChannels.stream().map(Channel::remoteAddress).filter(a -> a.getClass() == InetSocketAddress.class)
494+
Map<String, Long> totalConnectionsPerHost = openChannels.stream().map(Channel::remoteAddress).filter(a -> a instanceof InetSocketAddress)
494495
.map(a -> (InetSocketAddress) a).map(InetSocketAddress::getHostString).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
495496
Map<String, Long> idleConnectionsPerHost = channelPool.getIdleChannelCountPerHost();
496497
Map<String, HostStats> statsPerHost = totalConnectionsPerHost.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> {

0 commit comments

Comments
 (0)