未验证 提交 fe04ce84 编写于 作者: M Matteo Merli 提交者: GitHub

Avoid NullPointerException in ZK server stats collection (#2710)

上级 1f373262
......@@ -20,6 +20,7 @@ package org.apache.pulsar.zookeeper;
import io.prometheus.client.Gauge;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
......@@ -71,7 +72,12 @@ public class ZooKeeperServerAspect {
.setChild(new Gauge.Child() {
@Override
public double get() {
return zkServer.serverStats().getNumAliveClientConnections();
ServerCnxnFactory cnxFactory = zkServer.getServerCnxnFactory();
if (cnxFactory != null) {
return cnxFactory.getNumAliveConnections();
} else {
return -1;
}
}
}).register();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册