Skip to content

Cleanup ThreadContext in finally-clause#294

Merged
gupele merged 2 commits into
microsoft:masterfrom
jgogstad:bugfix/memory_leak
Aug 1, 2016
Merged

Cleanup ThreadContext in finally-clause#294
gupele merged 2 commits into
microsoft:masterfrom
jgogstad:bugfix/memory_leak

Conversation

@jgogstad

Copy link
Copy Markdown
Contributor

Fixes #292

@msftclas

Copy link
Copy Markdown

Hi @jgogstad, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. Real humans will now evaluate your PR.

TTYL, MSBOT;

@OriYosefiMSFT

Copy link
Copy Markdown
Member

Thanks for contributing the solution. I understand the issue you are reporting but I'm concerned that the proposed code may have an issue as well.
webModulesContainer.invokeOnEndRequest would invoke the module's OnEndRequest which uses the TLS (e.g. here ).
After the proposed changed, the TLS would have already been cleaned up in the "finally" clause.

@@ -181,10 +182,6 @@ private boolean invokeSafeOnBeginRequest(ServletRequest req, ServletResponse res
private void invokeSafeOnEndRequest(ServletRequest req, ServletResponse res) {
try {
webModulesContainer.invokeOnEndRequest(req, res);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This call invokes the modules' onEndRequest method which uses the TLS. After cleanup above, the TLS would no longer be available

@jgogstad

jgogstad commented Aug 1, 2016

Copy link
Copy Markdown
Contributor Author

True, sorry for the lack of proper testing on my part. Pushed a fix that also addresses #298. I restructured the conditionals a bit in order to make the exception handling more readable. As long as you're targeting JRE 1.6, we can't collapse the catch-blocks so the code is duplicated.

@gupele

gupele commented Aug 1, 2016

Copy link
Copy Markdown
Contributor

Thanks for the fix!

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