pinpoint-apm/pinpoint · error · java.lang.NullPointerException
NullPointerException
Error message
NullPointerException
What it means
This concurrent map does not permit null values, so containsValue(Object value) throws NullPointerException immediately when value is null instead of returning false. This is the standard java.util.concurrent contract (matching ConcurrentHashMap).
Source
Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/concurrent/jsr166/ConcurrentWeakHashMap.java:887
public boolean containsKey(Object key) {
int hash = hash(key.hashCode());
return segmentFor(hash).containsKey(key, hash);
}
/**
* Returns <tt>true</tt> if this map maps one or more keys to the
* specified value. Note: This method requires a full internal
* traversal of the hash table, and so is much slower than
* method <tt>containsKey</tt>.
*
* @param value value whose presence in this map is to be tested
* @return <tt>true</tt> if this map maps one or more keys to the
* specified value
* @throws NullPointerException if the specified value is null
*/
public boolean containsValue(Object value) {
if (value == null)
throw new NullPointerException();
// See explanation of modCount use above
final Segment<K,V>[] segments = this.segments;
int[] mc = new int[segments.length];
// Try a few times without locking
for (int k = 0; k < RETRIES_BEFORE_LOCK; ++k) {
int sum = 0;
int mcsum = 0;
for (int i = 0; i < segments.length; ++i) {
int c = segments[i].count;
mcsum += mc[i] = segments[i].modCount;
if (segments[i].containsValue(value))
return true;
}
boolean cleanSweep = true;
if (mcsum != 0) {View on GitHub (pinned to 744c3d3075)
Solutions
- Check for null before calling containsValue and treat null as 'not present'
- Do not use values().contains(null); write an explicit null check
- If nulls must be representable, switch to a map implementation that allows null values (e.g. HashMap) with external synchronization
Example fix
// before boolean found = map.containsValue(maybeNull); // after boolean found = maybeNull != null && map.containsValue(maybeNull);
Defensive patterns
Strategy: type-guard
Validate before calling
boolean safeContains(ConcurrentWeakHashMap<K,V> map, V v) { return v != null && map.containsValue(v); } Type guard
boolean nonNull(Object o) { return o != null; } Try / catch
try { return map.containsValue(value); } catch (NullPointerException e) { return false; } Prevention
- Remember all java.util.concurrent maps reject null keys and null values
- Null-check values coming from external lookups before membership tests
- Avoid values().contains(nullable) patterns
When it happens
Trigger: Calling map.containsValue(null) — commonly via Collection.contains(null) on map.values() or searching values for a nullable variable.
Common situations: Passing a method parameter or lookup result that is null into containsValue; calling values().contains(nullableVar) expecting false like HashMap does.
Related errors
- IllegalArgumentException
- NoSuchElementException
- IllegalStateException
- %s load fail Caused by:%s
- J9BootLoader create fail Caused by:
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/077664cb40499b4f.
Report an issue: GitHub.