{"record":{"id":"fafc850f683aec1e","repo":"apache/hadoop","slug":"arraylist-key-can-not-be-null","errorCode":null,"errorMessage":"ArrayList<Key> can not be null","messagePattern":"ArrayList<Key> can not be null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/RetouchedBloomFilter.java","lineNumber":172,"sourceCode":"   * @param coll The collection of false positive.\n   */\n  public void addFalsePositive(Collection<Key> coll) {\n    if (coll == null) {\n      throw new NullPointerException(\"Collection<Key> can not be null\");\n    }\n    \n    for (Key k : coll) {\n      addFalsePositive(k);\n    }\n  }\n\n  /**\n   * Adds a list of false positive information to <i>this</i> retouched Bloom filter.\n   * @param keys The list of false positive.\n   */\n  public void addFalsePositive(List<Key> keys) {\n    if (keys == null) {\n      throw new NullPointerException(\"ArrayList<Key> can not be null\");\n    }\n\n    for (Key k : keys) {\n      addFalsePositive(k);\n    }\n  }\n\n  /**\n   * Adds an array of false positive information to <i>this</i> retouched Bloom filter.\n   * @param keys The array of false positive.\n   */\n  public void addFalsePositive(Key[] keys) {\n    if (keys == null) {\n      throw new NullPointerException(\"Key[] can not be null\");\n    }\n\n    for (int i = 0; i < keys.length; i++) {\n      addFalsePositive(keys[i]);","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/RetouchedBloomFilter.java#L154-L190","documentation":"The List overload mirrors the Collection one, but its message still says 'ArrayList<Key>' because the API was originally written against ArrayList. It throws NullPointerException when the List reference itself is null, before the iteration starts.","triggerScenarios":"rbf.addFalsePositive((List<Key>) null); a List local that an early-return path left null; chaining a helper whose contract permits null returns.","commonSituations":"Refactors from ArrayList parameters to List with partial null handling; builder helpers that return null instead of an empty list on 'no data'.","solutions":["Pass Collections.emptyList() or a new ArrayList<Key>() when the list is absent","Null-check the List before the call","Make your own helpers never return null collections"],"exampleFix":"// before\nrbf.addFalsePositive(keys); // keys may be null -> NPE\n\n// after\nList<Key> safe = (keys == null) ? Collections.<Key>emptyList() : keys;\nrbf.addFalsePositive(safe);","handlingStrategy":"validation","validationCode":"List<Key> safe = (keys == null) ? Collections.<Key>emptyList() : keys;\nrbf.addFalsePositive(safe);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on empty-list-instead-of-null in your data layer","Check for null before every bulk call on optionally-absent lists","Note the message says ArrayList even though the parameter is List - search both when grepping logs"],"tags":["hadoop","bloom-filter","java","null-check","collections"],"backgroundTag":"null-argument-exception","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}