jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r356747 - /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
Date Wed, 14 Dec 2005 08:13:28 GMT
Author: mreutegg
Date: Wed Dec 14 00:13:24 2005
New Revision: 356747

URL: http://svn.apache.org/viewcvs?rev=356747&view=rev
Log:
Remove shutdown hook when repository is shut down.
See: http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4821

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java?rev=356747&r1=356746&r2=356747&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
Wed Dec 14 00:13:24 2005
@@ -55,7 +55,7 @@
  * <p>
  * A JVM shutdown hook is used to make sure that the initialized
  * repository is properly closed when the JVM shuts down. The
- * {@link RegistryHelper#unregisterRepository(Context, String)}
+ * {@link RegistryHelper#unregisterRepository(javax.naming.Context, String)}
  * method should be used to explicitly close the repository if
  * needed. 
  */
@@ -83,6 +83,12 @@
     private transient Repository delegatee;
 
     /**
+     * Thread that is registered as shutdown hook after {@link #init} has been
+     * called.
+     */
+    private transient Thread hook;
+    
+    /**
      * Creates a BindableRepository instance with the given configuration
      * information, but does not create the underlying repository instance.
      *
@@ -122,11 +128,13 @@
         RepositoryConfig config =
             RepositoryConfig.create(configFilePath, repHomeDir);
         delegatee = RepositoryImpl.create(config);
-        Runtime.getRuntime().addShutdownHook(new Thread() {
+        hook = new Thread() {
             public void run() {
                 shutdown();
             }
-        });
+        };
+
+        Runtime.getRuntime().addShutdownHook(hook);
     }
 
     //-----------------------------------------------------------< Repository >
@@ -246,6 +254,11 @@
      * Delegated to the underlying repository instance.
      */
     void shutdown() {
-    	((RepositoryImpl) delegatee).shutdown() ;
+        ((RepositoryImpl) delegatee).shutdown();
+        try {
+            Runtime.getRuntime().removeShutdownHook(hook);
+        } catch (IllegalStateException e) {
+            // ignore. exception is thrown when hook itself calls shutdown
+        }
     }
 }



Mime
View raw message