[ 
https://issues.apache.org/jira/browse/DERBY-3745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611962#action_12611962
 ] 

Knut Anders Hatlen commented on DERBY-3745:
-------------------------------------------

I don't know enough about class loading issues to tell whether or not the 
approach is OK. A couple of questions, though:

  - Is it Derby's responsibility to set the context class loader for every 
thread that it spawns, or should the application rather set the context class 
loader to the appropriate value (null?) when loading the Derby driver? It 
sounds to me like Derby behaves as expected by using the current context class 
loader, and I don't know if changing it could cause problems in other scenarios.

  - Does Derby prevent the class loader from being garbage collected after the 
driver has been unloaded? If not, I would think it was the application's 
responsibility to unload the driver when it wants all resources to be freed.

Other than that, the patch looks fine to me. Some nits:
- You may want to use spaces instead of tabs in SingletonTimerFactory, since 
that's what's used in the rest of the file.
- Some of the @param tags in PrivilegedThreadOps are empty.
- SecurityException is a RuntimeException, so the PrivilegedThreadOps should 
use PrivilegedAction instead of PrivilegedExceptionAction (if the code in the 
catch block is ever executed, the cast to SecurityException is guaranteed to 
fail since PrivilegedActionExceptions only wrap checked exceptions).
- Typo in javadoc for setCCLIfPrivileged: priveleged --> privileged

> Derby can leak classloaders in an app server environment
> --------------------------------------------------------
>
>                 Key: DERBY-3745
>                 URL: https://issues.apache.org/jira/browse/DERBY-3745
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>         Attachments: derby-3745_10.3_diff.txt
>
>
> A user reported potential class loader leaks in Derby
> ...The first one looks like Derby created a long-running
> thread and copying the context class loader.  To fix, the
> context class loader should be saved/set/restored around the
> creation of the new thread so that it copies some benign class
> loader instead (e.g., null or getClass().getClassLoader()):
>  0x42278e58 java/lang/[EMAIL PROTECTED]
>   [truncating at running thread LEAK]
> Object:  0x42278e58 java/lang/[EMAIL PROTECTED]
> Children:
>  0x42278ee0 java/lang/[EMAIL PROTECTED]
>  0x4226e558 java/lang/[EMAIL PROTECTED]
>  0x42278e40
> org/apache/derby/impl/services/monitor/[EMAIL PROTECTED]
>  0x419cfac0
> The second is another long running thread.  The same applies:
>  0x426fe7a0 java/lang/[EMAIL PROTECTED]
>   [truncating at running thread LEAK]
> Object:  0x426fe7a0 java/lang/[EMAIL PROTECTED]
> Parents:
>  0x4226e5a8 [Ljava/lang/Thread;@6f386f38
>  0x426fe548
> org/apache/derby/iapi/services/context/[EMAIL PROTECTED]
> Children:
>  0x426fe838 java/lang/[EMAIL PROTECTED]
>  0x4226e558 java/lang/[EMAIL PROTECTED]
>  0x426fe4f8
> org/apache/derby/impl/services/daemon/[EMAIL PROTECTED]
>  0x419cfac0
> The third is a TimerThread owneed , which is created when a
> Timer is created.  The same applies:
>  0x425ac538 java/util/[EMAIL PROTECTED]
>   [truncating at running thread LEAK]
> Object:  0x425ac538 java/util/[EMAIL PROTECTED]
> Parents:
>  0x41faaf58 [Ljava/lang/Thread;@3c583c58
> Object:  0x425ac510 java/util/[EMAIL PROTECTED]
> Parents:
>  0x425ac500
> org/apache/derby/impl/services/timer/[EMAIL PROTECTED]
> 6e2
> For more info, see thread at:
> http://www.nabble.com/ClassLoader-leaks--td18121374.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to