{"record":{"id":"f303782a77e83a36","repo":"apache/hadoop","slug":"identifier-cannot-be-null","errorCode":null,"errorMessage":"Identifier cannot be null","messagePattern":"Identifier cannot be null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RefreshRegistry.java","lineNumber":67,"sourceCode":"  }\n\n  private final Multimap<String, RefreshHandler> handlerTable;\n\n  public RefreshRegistry() {\n    handlerTable = HashMultimap.create();\n  }\n\n  /**\n   * Registers an object as a handler for a given identity.\n   * Note: will prevent handler from being GC'd, object should unregister itself\n   *  when done\n   * @param identifier a unique identifier for this resource,\n   *                   such as org.apache.hadoop.blacklist\n   * @param handler the object to register\n   */\n  public synchronized void register(String identifier, RefreshHandler handler) {\n    if (identifier == null) {\n      throw new NullPointerException(\"Identifier cannot be null\");\n    }\n    handlerTable.put(identifier, handler);\n  }\n\n  /**\n   * Remove the registered object for a given identity.\n   * @param identifier the resource to unregister\n   * @param handler input handler.\n   * @return the true if removed\n   */\n  public synchronized boolean unregister(String identifier, RefreshHandler handler) {\n    return handlerTable.remove(identifier, handler);\n  }\n\n  public synchronized void unregisterAll(String identifier) {\n    handlerTable.removeAll(identifier);\n  }\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RefreshRegistry.java#L49-L85","documentation":"RefreshRegistry.register maps a refresh identifier (conventionally a reverse-DNS string like 'org.apache.hadoop.example') to a RefreshHandler so dfsadmin/rmadmin-style refresh requests can reach it. A null identifier throws NullPointerException immediately as a fail-fast guard, since null can never be dispatched to by name.","triggerScenarios":"Calling RefreshRegistry.defaultRegistry().register(null, handler); identifiers built from configuration values or annotations where the lookup returned null.","commonSituations":"Custom refreshable plugins registering handlers during service init; identifier strings read from a config key that is absent; refactors that changed the identifier source to something nullable.","solutions":["Pass a unique, stable, non-null identifier (reverse-DNS convention) when registering.","If the identifier comes from configuration, validate the key exists at startup and fail with a clear message instead of registering null.","Wrap registration in a helper that does Objects.requireNonNull(identifier, ...) so the failure names the problem."],"exampleFix":"// before\nString id = conf.get(\"my.refresh.identifier\"); // null if key missing\nRefreshRegistry.defaultRegistry().register(id, handler);\n// after\nString id = Objects.requireNonNull(\n    conf.get(\"my.refresh.identifier\"),\n    \"my.refresh.identifier must be configured\");\nRefreshRegistry.defaultRegistry().register(id, handler);","handlingStrategy":"validation","validationCode":"String id = Objects.requireNonNull(identifierSource(),\n    \"refresh identifier source returned null\");\nif (id.isEmpty()) {\n  throw new IllegalArgumentException(\"refresh identifier must not be empty\");\n}\nRefreshRegistry.defaultRegistry().register(id, handler);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive refresh identifiers from constants, not loose config lookups.","Register handlers during service init, after config has already been validated.","Unregister (unregister/unregisterAll) on service stop to avoid leaks from the registry's strong references."],"tags":["refresh","registry","null-check","admin","plugin"],"backgroundTag":"null-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}