Skip to content

Conversation

@indigophox
Copy link
Contributor

@indigophox indigophox commented Jun 16, 2025

LazyStorage passes its ContextStorageProvider.class to ServiceLoader.load(). However, this is done from the LazyStorage static initializer, so the application has little to no control over the execution thread context for this code, and by default ServiceLoader uses the Thread context classloader, which may or may not have a different instance of ContextStorageProvider and its desendants.

This patch passes the classloader from LazyStorage to ServiceLoader so that it is able to find true (rather than just symbolic) descendants of that same class. Otherwise, if OpenTelemetry is loaded in a multi-classloader application, it can easily end up throwing a ServiceConfigurationError because ServiceLoader sees a different set of class instances than the set which the passed-in ContextStorageProvider.class is from.

@indigophox indigophox requested a review from a team as a code owner June 16, 2025 22:00
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: indigophox / name: Paul Nienaber (3ea9ba5)

@codecov
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.75%. Comparing base (cc2844d) to head (3ea9ba5).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7424   +/-   ##
=========================================
  Coverage     89.75%   89.75%           
  Complexity     6980     6980           
=========================================
  Files           797      797           
  Lines         21165    21165           
  Branches       2057     2057           
=========================================
  Hits          18996    18996           
  Misses         1505     1505           
  Partials        664      664           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@indigophox indigophox changed the title Patch LazyStorage to pass its ClassLoader to ServiceLoader fixes #7427: Patch LazyStorage to pass its ClassLoader to ServiceLoader Jun 16, 2025
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good thanks!

@jkwatson
Copy link
Contributor

@indigophox we need your commits to be associated with a github account which has signed the CNCF CLA.

@indigophox
Copy link
Contributor Author

@jkwatson got it, I will rattle the grapevine here tomorrow. Thank you!

@indigophox
Copy link
Contributor Author

Ok CLA stuff appears to be sorted.

@indigophox
Copy link
Contributor Author

Thank you! Is it possible to get this into a point or minor release soon-ish? This bug is blocking a release for us.

@jkwatson
Copy link
Contributor

We wouldn't normally do a special release for this kind of change, but just fold it into the next release, as we generally only issue mid-cycle patches for security issues or new bugs that were introduced. Exceptions can be made, but they would need to be exceptional.

The next release should be the 2nd week of July, I believe.

@indigophox
Copy link
Contributor Author

Sounds like we are good to wait on our end. Thanks again!

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jack-berg jack-berg merged commit 9329f86 into open-telemetry:main Jun 24, 2025
28 checks passed
@indigophox
Copy link
Contributor Author

Thank -you-! We're the ones blocked on this and appreciate it moving ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants