You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/01/11 14:19:33 UTC

svn commit: r1557385 - in /commons/proper/exec/trunk/src/main/java/org/apache/commons/exec: ProcessDestroyer.java ShutdownHookProcessDestroyer.java environment/DefaultProcessingEnvironment.java util/DebugUtils.java

Author: sebb
Date: Sat Jan 11 13:19:33 2014
New Revision: 1557385

URL: http://svn.apache.org/r1557385
Log:
Tab police (also fix trailing spaces in these files)

Modified:
    commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ProcessDestroyer.java
    commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
    commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
    commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/DebugUtils.java

Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ProcessDestroyer.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ProcessDestroyer.java?rev=1557385&r1=1557384&r2=1557385&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ProcessDestroyer.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ProcessDestroyer.java Sat Jan 11 13:19:33 2014
@@ -20,38 +20,38 @@ package org.apache.commons.exec;
 
 /**
  * Destroys all registered {@link java.lang.Process} after a certain event,
- * typically when the VM exits 
+ * typically when the VM exits
  * @see org.apache.commons.exec.ShutdownHookProcessDestroyer
  *
  * @version $Id$
  */
 public interface ProcessDestroyer {
 
-	/**
-	 * Returns <code>true</code> if the specified 
-	 * {@link java.lang.Process} was
-	 * successfully added to the list of processes to be destroy.
-	 * 
-	 * @param process
-	 *      the process to add
-	 * @return <code>true</code> if the specified 
-	 * 		{@link java.lang.Process} was
-	 *      successfully added
-	 */
-	boolean add(Process process);
-	
-	/**
-	 * Returns <code>true</code> if the specified 
-	 * {@link java.lang.Process} was
-	 * successfully removed from the list of processes to be destroy.
-	 * 
-	 * @param process
-	 *            the process to remove
-	 * @return <code>true</code> if the specified 
-	 * 		{@link java.lang.Process} was
-	 *      successfully removed
-	 */
-	boolean remove(Process process);
+    /**
+     * Returns <code>true</code> if the specified
+     * {@link java.lang.Process} was
+     * successfully added to the list of processes to be destroy.
+     *
+     * @param process
+     *      the process to add
+     * @return <code>true</code> if the specified
+     *      {@link java.lang.Process} was
+     *      successfully added
+     */
+    boolean add(Process process);
+
+    /**
+     * Returns <code>true</code> if the specified
+     * {@link java.lang.Process} was
+     * successfully removed from the list of processes to be destroy.
+     *
+     * @param process
+     *            the process to remove
+     * @return <code>true</code> if the specified
+     *      {@link java.lang.Process} was
+     *      successfully removed
+     */
+    boolean remove(Process process);
 
     /**
      * Returns the number of registered processes.

Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java?rev=1557385&r1=1557384&r2=1557385&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java Sat Jan 11 13:19:33 2014
@@ -40,7 +40,7 @@ public class ShutdownHookProcessDestroye
     /**
      * Whether or not this ProcessDestroyer is currently running as shutdown hook
      */
-  	private volatile boolean running = false;
+    private volatile boolean running = false;
 
     private class ProcessDestroyerImpl extends Thread {
 
@@ -87,77 +87,77 @@ public class ShutdownHookProcessDestroye
         }
     }
 
-	/**
-	 * Removes this <code>ProcessDestroyer</code> as a shutdown hook, uses
-	 * reflection to ensure pre-JDK 1.3 compatibility
-	 */
-	private void removeShutdownHook() {
-		if (added && !running) {
-			final boolean removed = Runtime.getRuntime().removeShutdownHook(
-					destroyProcessThread);
-			if (!removed) {
-				System.err.println("Could not remove shutdown hook");
-			}
-			/*
-			 * start the hook thread, a unstarted thread may not be eligible for
-			 * garbage collection Cf.: http://developer.java.sun.com/developer/
-			 * bugParade/bugs/4533087.html
-			 */
-
-			destroyProcessThread.setShouldDestroy(false);
-			destroyProcessThread.start();
-			// this should return quickly, since it basically is a NO-OP.
-			try {
-				destroyProcessThread.join(20000);
-			} catch (final InterruptedException ie) {
-				// the thread didn't die in time
-				// it should not kill any processes unexpectedly
-			}
-			destroyProcessThread = null;
-			added = false;
-		}
-	}
-
-	/**
-	 * Returns whether or not the ProcessDestroyer is registered as as shutdown
-	 * hook
-	 * 
-	 * @return true if this is currently added as shutdown hook
-	 */
-	public boolean isAddedAsShutdownHook() {
-		return added;
-	}
-
-	/**
-	 * Returns <code>true</code> if the specified <code>Process</code> was
-	 * successfully added to the list of processes to destroy upon VM exit.
-	 * 
-	 * @param process
-	 *            the process to add
-	 * @return <code>true</code> if the specified <code>Process</code> was
-	 *         successfully added
-	 */
-	public boolean add(final Process process) {
-		synchronized (processes) {
-			// if this list is empty, register the shutdown hook
-			if (processes.size() == 0) {
-				addShutdownHook();
-			}
-			processes.addElement(process);
-			return processes.contains(process);
-		}
-	}
-
-	/**
-	 * Returns <code>true</code> if the specified <code>Process</code> was
-	 * successfully removed from the list of processes to destroy upon VM exit.
-	 * 
-	 * @param process
-	 *            the process to remove
-	 * @return <code>true</code> if the specified <code>Process</code> was
-	 *         successfully removed
-	 */
-	public boolean remove(final Process process) {
+    /**
+     * Removes this <code>ProcessDestroyer</code> as a shutdown hook, uses
+     * reflection to ensure pre-JDK 1.3 compatibility
+     */
+    private void removeShutdownHook() {
+        if (added && !running) {
+            final boolean removed = Runtime.getRuntime().removeShutdownHook(
+                    destroyProcessThread);
+            if (!removed) {
+                System.err.println("Could not remove shutdown hook");
+            }
+            /*
+             * start the hook thread, a unstarted thread may not be eligible for
+             * garbage collection Cf.: http://developer.java.sun.com/developer/
+             * bugParade/bugs/4533087.html
+             */
+
+            destroyProcessThread.setShouldDestroy(false);
+            destroyProcessThread.start();
+            // this should return quickly, since it basically is a NO-OP.
+            try {
+                destroyProcessThread.join(20000);
+            } catch (final InterruptedException ie) {
+                // the thread didn't die in time
+                // it should not kill any processes unexpectedly
+            }
+            destroyProcessThread = null;
+            added = false;
+        }
+    }
+
+    /**
+     * Returns whether or not the ProcessDestroyer is registered as as shutdown
+     * hook
+     *
+     * @return true if this is currently added as shutdown hook
+     */
+    public boolean isAddedAsShutdownHook() {
+        return added;
+    }
+
+    /**
+     * Returns <code>true</code> if the specified <code>Process</code> was
+     * successfully added to the list of processes to destroy upon VM exit.
+     *
+     * @param process
+     *            the process to add
+     * @return <code>true</code> if the specified <code>Process</code> was
+     *         successfully added
+     */
+    public boolean add(final Process process) {
+        synchronized (processes) {
+            // if this list is empty, register the shutdown hook
+            if (processes.size() == 0) {
+                addShutdownHook();
+            }
+            processes.addElement(process);
+            return processes.contains(process);
+        }
+    }
+
+    /**
+     * Returns <code>true</code> if the specified <code>Process</code> was
+     * successfully removed from the list of processes to destroy upon VM exit.
+     *
+     * @param process
+     *            the process to remove
+     * @return <code>true</code> if the specified <code>Process</code> was
+     *         successfully removed
+     */
+    public boolean remove(final Process process) {
         synchronized (processes) {
             final boolean processRemoved = processes.removeElement(process);
             if (processRemoved && processes.size() == 0) {
@@ -165,7 +165,7 @@ public class ShutdownHookProcessDestroye
             }
             return processRemoved;
         }
-	}
+    }
 
   /**
    * Returns the number of registered processes.
@@ -177,8 +177,8 @@ public class ShutdownHookProcessDestroye
   }
 
   /**
-	 * Invoked by the VM when it is exiting.
-	 */
+     * Invoked by the VM when it is exiting.
+     */
   public void run() {
       synchronized (processes) {
           running = true;

Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java?rev=1557385&r1=1557384&r2=1557385&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java Sat Jan 11 13:19:33 2014
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -68,7 +68,7 @@ public class DefaultProcessingEnvironmen
      * Find the list of environment variables for this process.
      *
      * @return a amp containing the environment variables
-     * @throws IOException the operation failed 
+     * @throws IOException the operation failed
      */
     protected Map<String, String> createProcEnvironment() throws IOException {
         if (procEnvironment == null) {
@@ -112,7 +112,7 @@ public class DefaultProcessingEnvironmen
     /**
      * Start a process to list the environment variables.
      *
-     * @return a reader containing the output of the process 
+     * @return a reader containing the output of the process
      * @throws IOException starting the process failed
      * @deprecated No longer needed
      */
@@ -141,7 +141,7 @@ public class DefaultProcessingEnvironmen
 //        if (OS.isFamilyOS2()) {
 //            // OS/2 - use same mechanism as Windows 2000
 //            executable = "cmd";
-//            
+//
 //            arguments = new String[] {"/c", "set"};
 //        } else if (OS.isFamilyWindows()) {
 //            // Determine if we're running under XP/2000/NT or 98/95
@@ -184,7 +184,7 @@ public class DefaultProcessingEnvironmen
 //    /**
 //     * ByteArrayOutputStream#toString doesn't seem to work reliably on OS/390,
 //     * at least not the way we use it in the execution context.
-//     * 
+//     *
 //     * @param bos
 //     *            the output stream that one wants to read
 //     * @return the output stream as a string, read with special encodings in the
@@ -211,7 +211,7 @@ public class DefaultProcessingEnvironmen
      * Creates a map that obeys the casing rules of the current platform for key
      * lookup. E.g. on a Windows platform, the map keys will be
      * case-insensitive.
-     * 
+     *
      * @return The map for storage of environment variables, never
      *         <code>null</code>.
      */
@@ -223,7 +223,7 @@ public class DefaultProcessingEnvironmen
                 }
             });
         }
-		return new HashMap<String, String>();
+        return new HashMap<String, String>();
     }
 
 }

Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/DebugUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/DebugUtils.java?rev=1557385&r1=1557384&r2=1557385&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/DebugUtils.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/DebugUtils.java Sat Jan 11 13:19:33 2014
@@ -57,8 +57,8 @@ public class DebugUtils
             if (e instanceof RuntimeException) {
                 throw (RuntimeException) e;
             }
-			// can't pass root cause since the constructor is not available on JDK 1.3
-			throw new RuntimeException(e.getMessage());
+            // can't pass root cause since the constructor is not available on JDK 1.3
+            throw new RuntimeException(e.getMessage());
         }
     }