{"record":{"id":"a94549414d474203","repo":"apache/hadoop","slug":"zookeeper-client-is-null","errorCode":null,"errorMessage":"Zookeeper client is null","messagePattern":"Zookeeper client is null","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/security/token/ZKDelegationTokenSecretManagerImpl.java","lineNumber":224,"sourceCode":"\n  @Override\n  protected void addOrUpdateToken(AbstractDelegationTokenIdentifier ident,\n      DelegationTokenInformation info, boolean isUpdate) throws Exception {\n    // Store the data in local memory first\n    currentTokens.put(ident, info);\n    super.addOrUpdateToken(ident, info, isUpdate);\n  }\n\n  private ZooKeeper getZooKeeperClient() throws IOException {\n    // get zookeeper client\n    ZooKeeper zookeeper = null;\n    try {\n      zookeeper = zkClient.getZookeeperClient().getZooKeeper();\n    } catch (Exception e) {\n      LOG.info(\"Cannot get zookeeper client \", e);\n    } finally {\n      if (zookeeper == null) {\n        throw new IOException(\"Zookeeper client is null\");\n      }\n    }\n    return zookeeper;\n  }\n}\n","sourceCodeStart":206,"sourceCodeEnd":230,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/security/token/ZKDelegationTokenSecretManagerImpl.java#L206-L230","documentation":"getZooKeeperClient() obtains the underlying org.apache.zookeeper.ZooKeeper handle from the Curator client (zkClient.getZookeeperClient().getZooKeeper()). If Curator is null/not started or the call throws, it logs INFO 'Cannot get zookeeper client' with the cause and then throws IOException('Zookeeper client is null') in the finally block. Callers include rebuildTokenCache, which needs the raw client for unsorted getChildren over the token tree.","triggerScenarios":"The ZK token secret manager's Curator client was never started or lost its connection so getZookeeperClient() throws; the manager was constructed against an unreachable ZooKeeper ensemble; Curator is still connecting when a token cache rebuild runs.","commonSituations":"ZooKeeper ensemble down at router start or during a token cache refresh; wrong ZK connection string in the token manager configuration; ZK session expired and Curator has not re-established before the next rebuild.","solutions":["Look at the preceding INFO log 'Cannot get zookeeper client' — it carries the underlying exception (connection refused, auth failure, illegal state).","Verify ZooKeeper connectivity and connection string from the router host.","Ensure the manager is fully started (its startThreads runs during router initialization) before token operations trigger cache rebuilds.","Restart the router after ZooKeeper recovers; the handle cannot be re-obtained from a dead Curator client."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  zkClient.getChildren(TOKEN_PATH, false); // path using getZooKeeperClient()\n} catch (IOException e) {\n  if (\"Zookeeper client is null\".equals(e.getMessage())) {\n    // curator handle unavailable: check preceding 'Cannot get zookeeper client' log,\n    // restore ZK / restart the secret manager rather than retrying in-process\n    throw new IllegalStateException(\"ZK token store disconnected; restart after ZK recovery\", e);\n  }\n  throw e;\n}","preventionTips":["Start the ZK token secret manager only after the Curator client is connected (blockUntilConnected) so getZooKeeperClient never runs mid-connect.","Keep ZK connection config validated (ensemble, session timeout, auth) in router config checks.","Treat 'Cannot get zookeeper client' INFO logs as an early warning to investigate ZK health."],"tags":["hdfs","router-based-federation","delegation-token","zookeeper","curator"],"backgroundTag":"zookeeper-client-unavailable","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}