Describe the bug
Baggage.fromContext(Context context) and Baggage.fromContextOrNull(Context context) in Baggage currently throw NullPointerException when passed a null context because both dereference the supplied Context without a null guard.
Steps to reproduce
- To add check point in Baggage.fromContext(Context context) in Baggage with log returns
Baggage.empty().
- To add check point in Baggage.fromContextOrNull(Context context) in Baggage with log returns null.
- Finally, add testcase fromContext_null() in BaggageContextText to validate above changes.
What did you expect to see?
- Baggage.fromContext(Context context) should log using ApiUsageLogger and return Baggage.empty().
- Same way for Baggage.fromContextOrNull(null) should log using ApiUsageLogger and return null.
What did you see instead?
In the current scenario Baggage.fromContext(Context context) and Baggage.fromContextOrNull(Context contextl) throw NullPointerException when passed a null context for both the methods.
What version and what artifacts are you using?
Artifacts: opentelemetry-api
Version: main
How did you reference these artifacts? (excerpt from your build.gradle, pom.xml, etc)
Environment
Compiler: Temurin JDK 25
OS: Windows 11
Runtime (if different from JDK above): JDK 25
OS (if different from OS compiled on): (e.g., "Windows Server 2019")
Additional context
I did refer fromContext(context) and fromContextOrNull(context) method of Span.java implemented accordingly.
I'm happy get assign and work on this issue.
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
Baggage.fromContext(Context context) and Baggage.fromContextOrNull(Context context) in Baggage currently throw
NullPointerExceptionwhen passed anullcontext because both dereference the suppliedContextwithout a null guard.Steps to reproduce
Baggage.empty().What did you expect to see?
What did you see instead?
In the current scenario Baggage.fromContext(Context context) and Baggage.fromContextOrNull(Context contextl) throw
NullPointerExceptionwhen passed anullcontext for both the methods.What version and what artifacts are you using?
Artifacts:
opentelemetry-apiVersion: main
How did you reference these artifacts? (excerpt from your
build.gradle,pom.xml, etc)Environment
Compiler: Temurin JDK 25
OS: Windows 11
Runtime (if different from JDK above): JDK 25
OS (if different from OS compiled on): (e.g., "Windows Server 2019")
Additional context
I did refer fromContext(context) and fromContextOrNull(context) method of Span.java implemented accordingly.
I'm happy get assign and work on this issue.
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.