Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call Thread#setContextClassLoader() #7391

Merged

Conversation

mateuszrzeszutek
Copy link
Member

@mateuszrzeszutek mateuszrzeszutek commented Dec 12, 2022

Related to #7220

Unfortunately it doesn't fix the aforementioned issue; while the CL used is no longer the agent classloader, gauge collection still throws that error.
Still, I think this is a good change that removes one source of agent's CL leaking into application runtime.

@mateuszrzeszutek mateuszrzeszutek force-pushed the remove-setContextClassLoader branch from 885113f to 3b87003 Compare December 12, 2022 13:00
@mateuszrzeszutek mateuszrzeszutek changed the title Remove Thread#setContextClassLoader() calls Don't call Thread#setContextClassLoader() Dec 12, 2022
@mateuszrzeszutek mateuszrzeszutek marked this pull request as ready for review December 12, 2022 15:05
@mateuszrzeszutek mateuszrzeszutek requested a review from a team December 12, 2022 15:05
@trask trask added this to the v1.21.0 milestone Dec 13, 2022
Copy link
Contributor

@laurit laurit left a comment

Choose a reason for hiding this comment

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

fun withContextClassLoader(classLoader: ClassLoader, action: () -> Unit) {
val currentClassLoader = Thread.currentThread().contextClassLoader
Thread.currentThread().contextClassLoader = classLoader
try {
action()
} finally {
Thread.currentThread().contextClassLoader = currentClassLoader
}
}
shouldn't be needed after this

@trask
Copy link
Member

trask commented Dec 13, 2022

I'm going to merge to include this in release, I'll send PR to follow-up on @laurit's latest suggestion

@trask trask merged commit c03bfc2 into open-telemetry:main Dec 13, 2022
@mateuszrzeszutek mateuszrzeszutek deleted the remove-setContextClassLoader branch December 13, 2022 18:47
trask pushed a commit that referenced this pull request Dec 14, 2022
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.

3 participants