Commits

Marcin Gardias committed fde0c58

no auto-closing stdin

  • Participants
  • Parent commits 6777f22

Comments (0)

Files changed (2)

src/main/java/com/atlassian/utils/process/ClosingInputHandler.java

+package com.atlassian.utils.process;
+
+import org.apache.log4j.Logger;
+
+import java.io.OutputStream;
+
+/**
+ * Simple {@link InputHandler} than only closes the stream.
+ */
+public class ClosingInputHandler implements InputHandler
+{
+    private static final Logger log = Logger.getLogger(ClosingInputHandler.class);
+    // ------------------------------------------------------------------------------------------------------- Constants
+    // ------------------------------------------------------------------------------------------------- Type Properties
+    // ---------------------------------------------------------------------------------------------------- Dependencies
+    // ---------------------------------------------------------------------------------------------------- Constructors
+    // ----------------------------------------------------------------------------------------------- Interface Methods
+    // -------------------------------------------------------------------------------------------------- Action Methods
+    // -------------------------------------------------------------------------------------------------- Public Methods
+
+    public void complete()
+    {
+    }
+
+    public void process(final OutputStream input)
+    {
+        IOUtils.closeQuietly(input);
+    }
+
+    public void setWatchdog(final Watchdog watchdog)
+    {
+    }
+
+    // -------------------------------------------------------------------------------------- Basic Accessors / Mutators
+}

src/main/java/com/atlassian/utils/process/ExternalProcessImpl.java

                             handleHandlerError(name, t);
                         }
                     } finally {
-                        try {
-                            process.getOutputStream().close();
-                        } catch (IOException e) {
-                            ExternalProcessImpl.LOG.error("Error closing output stream", e);
-                        }
                     }
                 }
             };
         }
-        else
-        {
-            try
-            {
-                process.getOutputStream().close();
-            }
-            catch (IOException ioe)
-            {
-                ExternalProcessImpl.LOG.error("Error closing output stream", ioe);
-            }
-        }
 
         errorPump = new LatchedRunnable("StdErrHandler " + process) {