diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java index 8ea2057e6d0..742a728a79c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java @@ -169,8 +169,9 @@ public class NettyRpcServer extends RpcServer { @Override public int getNumOpenConnections() { + int channelsCount = allChannels.size(); // allChannels also contains the server channel, so exclude that from the count. - return allChannels.size() - 1; + return channelsCount > 0 ? channelsCount - 1 : channelsCount; } @Override