commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1023094 - /commons/proper/daemon/trunk/src/java/org/apache/commons/daemon/Main.java
Date Fri, 15 Oct 2010 20:08:05 GMT
Author: mturk
Date: Fri Oct 15 20:08:04 2010
New Revision: 1023094

URL: http://svn.apache.org/viewvc?rev=1023094&view=rev
Log:
Allow System.exit for shutdown method

Modified:
    commons/proper/daemon/trunk/src/java/org/apache/commons/daemon/Main.java

Modified: commons/proper/daemon/trunk/src/java/org/apache/commons/daemon/Main.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/java/org/apache/commons/daemon/Main.java?rev=1023094&r1=1023093&r2=1023094&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/java/org/apache/commons/daemon/Main.java (original)
+++ commons/proper/daemon/trunk/src/java/org/apache/commons/daemon/Main.java Fri Oct 15 20:08:04
2010
@@ -185,12 +185,19 @@ public class Main implements Daemon
         protected void invoke()
             throws Exception
         {
-            Object obj   = claz.newInstance();
-            Object arg[] = new Object[1];
-
-            arg[0] = args;
-            inst.invoke(obj, arg);
+            if (name.equals("System.exit")) {
+                // Just call a System.exit()
+                // The start method was probably installed
+                // a shutdown hook.
+                System.exit(0);
+            }
+            else {
+                Object obj   = claz.newInstance();
+                Object arg[] = new Object[1];
 
+                arg[0] = args;
+                inst.invoke(obj, arg);
+            }
         }
         // Load the class using reflection
         protected void validate()
@@ -199,6 +206,8 @@ public class Main implements Daemon
             /* Check the class name */
             if (name == null)
                 throw new NullPointerException("Null class name specified");
+            else if (name.equals("System.exit"))
+                return;
             if (args == null)
                 args = new String[0];
             if (main == null)



Mime
View raw message