db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1620598 - in /db/derby/code/branches/10.11: ./ java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
Date Tue, 26 Aug 2014 13:35:20 GMT
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;
         }



Mime
View raw message