Fix NPE error when NiFi connects to external zookeeper insecurely
This closes
@@ -38,6 +38,8 @@ import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.Code;
import org.apache.zookeeper.KeeperException.NoNodeException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZKUtil;
import org.apache.zookeeper.ZooDefs.Ids;
import org.apache.zookeeper.ZooKeeper;
@@ -213,14 +215,22 @@ public class ZooKeeperStateProvider extends AbstractStateProvider {
if(clientConfig != null && clientConfig.isClientSecure()) {
SecureClientZooKeeperFactory factory = new SecureClientZooKeeperFactory(clientConfig);
try {
- zooKeeper = factory.newZooKeeper(connectionString, timeoutMillis, null, true);
+ zooKeeper = factory.newZooKeeper(connectionString, timeoutMillis, new Watcher() {
+ @Override
+ public void process(WatchedEvent event) {
+ }
+ }, true);
logger.info("Secure Zookeeper client initialized successfully.");
} catch (Exception e) {
logger.error("Secure Zookeeper configuration failed!", e);
invalidateClient();
}
} else {
- zooKeeper = new ZooKeeper(connectionString, timeoutMillis, null);
+ zooKeeper = new ZooKeeper(connectionString, timeoutMillis, new Watcher() {
+ @Override
+ public void process(WatchedEvent event) {
+ }
+ });
}
if (auth != null) {
