[jboss-cvs] JBossAS SVN: r88882 - branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 14 13:09:40 EDT 2009


Author: ALRubinger
Date: 2009-05-14 13:09:40 -0400 (Thu, 14 May 2009)
New Revision: 88882

Modified:
   branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java
Log:
[JBAS-6856][JBBOOT-23] Close the URLCL under JDK7+ in the shutdown hook, not after start()

Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java	2009-05-14 17:06:15 UTC (rev 88881)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java	2009-05-14 17:09:40 UTC (rev 88882)
@@ -374,7 +374,7 @@
       config.properties(props).jbossHome(jbossHome);
       
       // Make a shutdown hook
-      SecurityActions.addShutdownHook(new ShutdownHook(server));
+      SecurityActions.addShutdownHook(new ShutdownHook(server,loadingCl));
 
       try
       {
@@ -391,22 +391,6 @@
       {
          // Reset the CL 
          SecurityActions.setThreadContextClassLoader(tccl);
-         
-         /*
-          * Close the URLCL, if JDK7+
-          * JBBOOT-23
-          */
-         if (loadingCl != null && loadingCl instanceof Closeable)
-         {
-            try
-            {
-               ((Closeable) loadingCl).close();
-            }
-            catch (IOException ioe)
-            {
-               // Swallow
-            }
-         }
       }
    }
 
@@ -863,16 +847,34 @@
        * Underlying server instance
        */
       private Server<?, ?> server;
+      
+      /**
+       * ClassLoader used to start/init the server
+       */
+      private ClassLoader serverCl;
 
       /**
        * Constructor
        * 
        * @param server
-       * @param exitCode
+       * @param serverCl The ClassLoader to be optionally closed upon shutdown
+       * @throws IllegalArgumentException If any argument is not supplied (null)
        */
-      ShutdownHook(final Server<?, ?> server)
+      ShutdownHook(final Server<?, ?> server,final ClassLoader serverCl) throws IllegalArgumentException
       {
+         // Precondition checks
+         if(server==null)
+         {
+            throw new IllegalArgumentException("server must be specified");
+         }
+         if(serverCl==null)
+         {
+            throw new IllegalArgumentException("server ClassLoader must be specified");
+         }
+         
+         // Set properties
          this.server = server;
+         this.serverCl = serverCl;
       }
 
       /**
@@ -902,6 +904,22 @@
                         // just run the hook, don't call System.exit, as we may
                         // be embeded in a vm that would not like that very much
                         server.shutdown();
+                        
+                        /*
+                         * Close the Loading CL, if URLCL and JDK7+
+                         * JBBOOT-23
+                         */
+                        if (serverCl != null && serverCl instanceof Closeable)
+                        {
+                           try
+                           {
+                              ((Closeable) serverCl).close();
+                           }
+                           catch (IOException ioe)
+                           {
+                              // Swallow
+                           }
+                        }
                      }
                      // In case of any Exception thrown up the chain, let us know
                      catch (final Exception e)




More information about the jboss-cvs-commits mailing list