Describe the bug
ReadOnlyArrayMap.containsValue(Object) from line 73 does not correctly handle maps that contain null values. The implementation assumes in the way of stored values are non-null and performs the comparison using equals(), which can result in incorrect behavior or a NullPointerException when a value in the map is null.
Steps to reproduce
- Update ReadOnlyArrayMap.containsValue(Object) which can handle null.
- Add appropriate testcase in ReadOnlyArrayMapTest.
What did you expect to see?
containsValue(null) should return true when the map contains a mapping whose value is null, consistent with the Map.containsValue().
What did you see instead?
containsValue(null) does not handle null values correctly because the implementation assumes in the way of stored values are non-null. This can lead to incorrect results or a NullPointerException when a map contains a null value.
What version and what artifacts are you using?
Artifacts: opentelemetry-api
Version: Latest main branch
How did you reference these artifacts? (excerpt from your build.gradle, pom.xml, etc)
Core OpenTelemetry Java API
Environment
Compiler: Oracle JDK 25.0.1 LTS (64-bit)
OS: Windows 11
Runtime (if different from JDK above): Oracle Java SE Runtime Environment (build 25.0.1+8-LTS-27)
OS (if different from OS compiled on): NA
Additional context
- Fix the null handling in ReadOnlyArrayMap.containsValue(null).
- Add appropriate testcase to ReadOnlyArrayMapTest.
I'm happy to be assigned this issue and work on fixing it!
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Describe the bug
ReadOnlyArrayMap.containsValue(Object) from line 73 does not correctly handle maps that contain null values. The implementation assumes in the way of stored values are non-null and performs the comparison using equals(), which can result in incorrect behavior or a NullPointerException when a value in the map is null.
Steps to reproduce
What did you expect to see?
containsValue(null) should return true when the map contains a mapping whose value is null, consistent with the Map.containsValue().
What did you see instead?
containsValue(null) does not handle null values correctly because the implementation assumes in the way of stored values are non-null. This can lead to incorrect results or a NullPointerException when a map contains a null value.
What version and what artifacts are you using?
Artifacts: opentelemetry-api
Version: Latest main branch
How did you reference these artifacts? (excerpt from your
build.gradle,pom.xml, etc)Core OpenTelemetry Java API
Environment
Compiler: Oracle JDK 25.0.1 LTS (64-bit)
OS: Windows 11
Runtime (if different from JDK above): Oracle Java SE Runtime Environment (build 25.0.1+8-LTS-27)
OS (if different from OS compiled on): NA
Additional context
I'm happy to be assigned this issue and work on fixing it!
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it. Learn more here.