db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1620392 - in /db/derby/code/branches/10.11: ./ java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
Date Mon, 25 Aug 2014 17:57:08 GMT
Author: dag
Date: Mon Aug 25 17:57:08 2014
New Revision: 1620392

URL: http://svn.apache.org/r1620392
Log:
DERBY-6619 After silently swallowing SecurityExceptions, Derby can leak class loaders

Backported from trunk svn 1620385.

Patch derby-6619-2-refinement which implements the following
refinements to the test to avoid changing the context class loader in
SingletonTimerFactory (suggested by Knut):

The orginal test tested against the system class loader. This new
patch will:

1) Check if the context class loader is the same as the loader of the
SingletonTimerFactory class (that is, the class loader from which
Derby classes are loaded). Even if this isn't the same as the system
class loader, it would be safe to skip the workaround for DERBY-3745,
since the class loader for the Derby classes would not be eligible for
garbage collection until the engine is shut down anyway. This would
prevent some more false positives from being reported in
derby.log. I'd assume this is a kind of false positive that could
easily occur in an application server environment where the Derby
classes are not found on the system class loader.

2) Check against Thread.class.getClassLoader() instead of
ClassLoader.getSystemClassLoader(). Normally, those two checks would
be identical. If however the setup is such that they aren't identical,
we'd still know that the class loader actually used for system classes
such as the Thread class would have to stay in memory for as long as
the timer thread is alive, regardless of the context class loader of
the thread, so the workaround for DERBY-3745 can be skipped if it's
the same as the context class loader. The check will be a bit more
specific this way.


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:r1620385

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=1620392&r1=1620391&r2=1620392&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
Mon Aug 25 17:57:08 2014
@@ -175,13 +175,14 @@ public class SingletonTimerFactory
                 public ClassLoader run() {
                     ClassLoader cl =
                         Thread.currentThread().getContextClassLoader();
-                    if (cl == ClassLoader.getSystemClassLoader()) {
-                        // If the context class loader is the same as the
-                        // system class loader, we are not worried that the
-                        // timer thread will lead a class loader. (The
-                        // system class loader will stay in memory for the
+                    if (cl == getClass().getClassLoader() ||
+                        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.)
+                        // that the timer thread keeps a reference to it.
                         // Return null to signal that the context class loader
                         // doesn't need to be changed.
                         return null;



Mime
View raw message