[ 
https://issues.apache.org/jira/browse/CAMEL-6452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13683135#comment-13683135
 ] 

Claus Ibsen commented on CAMEL-6452:
------------------------------------

First thanks for reporting this issue with the leak.

I think a better approach is to add a UtilService class in the util package. 
This class should extends ServiceSupport from the support package. Then we 
register this as a service to DefaultCamelContext in its doStartCamel() method.

Then we have callbacks for doStart / doStop in the UtilService class where we 
can do out needed logic, when Camel is starting / stopping.

This also means the default temp dir logic should be *per CamelContext* instead 
of *per JVM*. This also works much better in WAR containers / OSGi containers 
et all; where people can hot and redeploy apps. Having JVM hooks and static 
classes that are initialized with a == null check is (becoming) a bad practice 
IMHO.


                
> FileUtil.getDefaultTempDir() causes a classloader leak in webapps
> -----------------------------------------------------------------
>
>                 Key: CAMEL-6452
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6452
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.10.4
>         Environment: tomcat 7, spring 3.2
>            Reporter: Sanjay Deshmukh
>         Attachments: 
> 0001-Fixed-CAMEL-6452-by-adding-a-cleanup-routine-to-remo.patch
>
>
> FileUtil.getDefaultTempDir() registers a JVM shutdown hook to delete the 
> temporary directory it creates. We are using camel in a web application in 
> Tomcat that gets dynamically reloaded as updates are available, so the JVM is 
> normally never shut down. This is causing 'camel-tmp-*' directories to linger 
> in $CATALINA_HOME/temp, and - more importantly - classloader leaks, which are 
> a major problem for us.
> If the thread that gets registered as the shutdown hook were stored in a 
> class variable, I could unregister it when the application is being unloaded.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to