apache/hadoop · error · NullPointerException
Key[] can not be null
Error message
Key[] can not be null
What it means
The array overload throws NullPointerException when the Key[] reference is null. The per-element loop then forwards each slot to addFalsePositive(Key), so a null element inside a non-null array trips the per-key check instead.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/RetouchedBloomFilter.java:186
* @param keys The list of false positive.
*/
public void addFalsePositive(List<Key> keys) {
if (keys == null) {
throw new NullPointerException("ArrayList<Key> can not be null");
}
for (Key k : keys) {
addFalsePositive(k);
}
}
/**
* Adds an array of false positive information to <i>this</i> retouched Bloom filter.
* @param keys The array of false positive.
*/
public void addFalsePositive(Key[] keys) {
if (keys == null) {
throw new NullPointerException("Key[] can not be null");
}
for (int i = 0; i < keys.length; i++) {
addFalsePositive(keys[i]);
}
}
/**
* Performs the selective clearing for a given key.
* @param k The false positive key to remove from <i>this</i> retouched Bloom filter.
* @param scheme The selective clearing scheme to apply.
*/
public void selectiveClearing(Key k, short scheme) {
if (k == null) {
throw new NullPointerException("Key can not be null");
}
if (!membershipTest(k)) {View on GitHub (pinned to 2add963021)
Solutions
- Pass new Key[0] when the array is absent
- Null-check the array reference before the call
- Allocate arrays eagerly while building the batch
Example fix
// before rbf.addFalsePositive(keys); // keys may be null -> NPE // after rbf.addFalsePositive(keys != null ? keys : new Key[0]);
Defensive patterns
Strategy: validation
Validate before calling
rbf.addFalsePositive(keys != null ? keys : new Key[0]);
Prevention
- Allocate accumulator arrays eagerly when building batches
- Null-check array references that come from lazily-built buffers
- Remember null elements inside a non-null array still fail the per-key check
When it happens
Trigger: rbf.addFalsePositive((Key[]) null); array accumulators that start as null and are only lazily allocated; varargs call sites passing an uninitialized array.
Common situations: Accumulator patterns that grow arrays on demand; fixed-size buffers reused across batches where null marks 'not built yet'.
Related errors
- value can not be null
- key can not be null
- Collection<Key> can not be null
- ArrayList<Key> can not be null
- Key can not be null
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/2d80d3e0997d9bd8.
Report an issue: GitHub.