peony2012 / urlrewritefilter

Automatically exported from code.google.com/p/urlrewritefilter
Other
0 stars 0 forks source link

Class log should not refer to the ServletContext #102

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
> What version of the product are you using?
3.2
> On what operating system?
JDK 6, JBoss AS 7 with the JAR installed as a JBoss Module (not within the EAR).

If the filter is used within a web application, via web.xml, then the Log class 
keeps a reference to the application’s context. When the application is 
undeployed, the Log class keeps a reference to the context, hence a memory leak.

Current workaround:
In the web.xml of the application, add a Listener which on contextDestroyed 
call:
org.tuckey.web.filters.urlrewrite.utils.Log.resetAll();

However, in addition to this, is the filter is used for more than one web 
application, the settings will be overridden. 
A better solution would be that the log class contains only a static 
WeakHashMap of the log settings indexed by ServletContext. And then, the logger 
would use the settings thank to the current context of the processed 
ServletRequest.

Thank you.

Original issue reported on code.google.com by guinotp...@gmail.com on 13 Feb 2012 at 1:25

GoogleCodeExporter commented 9 years ago
Added call to Log.resetAll to destroy of UrlRewriteFilter to ensure that 
reference is let go when the context is destroyed.

If this doesn't reliably work I can make it a WeakReference to the context but 
I'd rather not if destroy is working ok.

Original comment by p...@tuckey.org on 25 Jun 2012 at 10:49