jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r469197 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java
Date Mon, 30 Oct 2006 17:06:23 GMT
Author: stefan
Date: Mon Oct 30 09:06:23 2006
New Revision: 469197

URL: http://svn.apache.org/viewvc?view=rev&rev=469197
Log:
catch IllegalStateException when registering shutdown hook

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java?view=diff&rev=469197&r1=469196&r2=469197
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java
Mon Oct 30 09:06:23 2006
@@ -80,20 +80,26 @@
         reaper.setDaemon(true);
         reaper.start();
         // register shutdownhook for final cleaning up
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            public void run() {
-                // synchronize on the list before iterating over it in order
-                // to avoid ConcurrentModificationException (JCR-549)
-                // @see java.lang.util.Collections.synchronizedList(java.util.List)
-                synchronized(trackedRefs) {
-                    for (Iterator it = trackedRefs.iterator(); it.hasNext();) {
-                        MoribundFileReference fileRef = (MoribundFileReference) it.next();
-                        fileRef.delete();
-                    }
+        try {
+            Runtime.getRuntime().addShutdownHook(new Thread() {
+                public void run() {
+                    // synchronize on the list before iterating over it in order
+                    // to avoid ConcurrentModificationException (JCR-549)
+                    // @see java.lang.util.Collections.synchronizedList(java.util.List)
+                    synchronized(trackedRefs) {
+                        for (Iterator it = trackedRefs.iterator(); it.hasNext();) {
+                            MoribundFileReference fileRef = (MoribundFileReference) it.next();
+                            fileRef.delete();
+                        }
 
+                    }
                 }
-            }
-        });
+            });
+        } catch (IllegalStateException e) {
+            // can't register shutdownhook because
+            // jvm shutdown sequence has already begun,
+            // silently ignore... 
+        }
     }
 
     //------------------------------------------------------< factory methods >



Mime
View raw message