You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by da...@apache.org on 2014/08/26 15:35:20 UTC
svn commit: r1620598 - in /db/derby/code/branches/10.11: ./
java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
Author: dag
Date: Tue Aug 26 13:35:19 2014
New Revision: 1620598
URL: http://svn.apache.org/r1620598
Log:
DERBY-6619 Improve comments
Backported from trunk svn 1620539 cleanly.
Modified:
db/derby/code/branches/10.11/ (props changed)
db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
Propchange: db/derby/code/branches/10.11/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1620539
Modified: db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java?rev=1620598&r1=1620597&r2=1620598&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java (original)
+++ db/derby/code/branches/10.11/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java Tue Aug 26 13:35:19 2014
@@ -160,12 +160,14 @@ public class SingletonTimerFactory
// Helper methods
/**
- * Get the context class loader if it's different from the system
- * class loader.
+ * Check if the current context class loader could cause a memory leak
+ * (DERBY-3745) if it is inherited by the timer thread, and return it if
+ * that is the case.
*
* @return the context class loader of the current thread if it is
- * different from the system class loader and we have permission
- * to read the class loader, or {@code null} otherwise
+ * not the same class loader as the one used by the system classes
+ * or the Derby classes and we have permission to read the class
+ * loaders, or {@code null} otherwise
*/
private ClassLoader getContextClassLoader() {
try {
@@ -179,10 +181,12 @@ public class SingletonTimerFactory
cl == Thread.class.getClassLoader()) {
// If the context class loader is the same as any of
// these class loaders, we are not worried that the
- // timer thread will lead a class loader. These
- // class loaders will stay in memory for the
- // lifetime of the JVM anyway, so it's not a problem
- // that the timer thread keeps a reference to it.
+ // timer thread will leak a class loader. These
+ // class loaders will stay in memory at least for the
+ // lifetime of the Derby engine anyway, so it's not
+ // a problem that the timer thread keeps a reference
+ // to any of them until the engine is shut down.
+ //
// Return null to signal that the context class loader
// doesn't need to be changed.
return null;
@@ -193,9 +197,14 @@ public class SingletonTimerFactory
});
} catch (SecurityException se) {
// Ignore security exception. Versions of Derby before
- // the DERBY-3745 fix did not require getContextClassLoader
+ // the DERBY-3745 fix did not require getClassLoader
// privileges. We may leak class loaders if we are not
// able to do this, but we can't just fail.
+ //
+ // In most cases the above calls will succeed, even if
+ // RuntimePermission("getClassLoader") has not been granted.
+ // See the javadoc for Thread.getContextClassLoader() and
+ // Class.getClassLoader() for details.
report(se, MessageId.CANNOT_GET_CLASSLOADER);
return null;
}