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

Cleanup thread local context in ThreadLocalContextManager after e… #422

Merged
merged 3 commits into from
Jun 21, 2017

Conversation

bretthoerner
Copy link

…ach servlet request finishes.


This is for #420.

The issue was that threadlocals still held references to classes that were loaded with the old classloader -- and there was nothing to ever remove those old references.

I did some research, and there's no way to remove threadlocals except from the thread that created them (which makes sense). So for now, the only place we do cleanup is in the SentryServletRequestListener. That should cover most bases, because the most common use of "make a new classloader and reload my entire app" is in application servers that are using servlets.

@@ -21,4 +21,9 @@ public Context getContext() {
return context.get();
}

@Override
public void clear() {
context.remove();
Copy link
Author

@bretthoerner bretthoerner Jun 20, 2017

Choose a reason for hiding this comment

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

This it the critical difference. The rest is dealing with abstractions/naming.

@bretthoerner
Copy link
Author

I guess it's worth noting that this won't help if a user sets context stuff in a non-servlet thread. I don't have a good solution there if they are loading/unloading/reloading classes.

CHANGES Outdated
@@ -2,7 +2,8 @@ Version 1.1.1
-------------

- Allow overriding the location of the properties file.
- Add support for handling and uploading Proguard files to Sentry (for Android applications).
- Add support for handling and uploading Proguard files to Sentry (for Android applications).'

Choose a reason for hiding this comment

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

s/'$//

@bretthoerner bretthoerner merged commit ad6e928 into master Jun 21, 2017
@bretthoerner bretthoerner deleted the clean-contexxt branch June 22, 2017 19:25
bruno-garcia pushed a commit that referenced this pull request Jun 12, 2020
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.

2 participants