Conor MacNeill avatar Conor MacNeill committed 0c1de2c

Initial move away from P4 specific process handling

Comments (0)

Files changed (4)

processutils/src/main/java/com/atlassian/utils/process/BaseOutputHandler.java

         watchdog.cancel();
     }
 
-    public void complete() {
+    public void complete() throws ProcessException {
     }
 }

processutils/src/main/java/com/atlassian/utils/process/ExternalProcessBuilder.java

 
 
 /**
- * Utility class to simply the building of an ExternalProcess instance
+ * Utility class to simplify the building of an ExternalProcess instance
  *
  */
 public class ExternalProcessBuilder {
     private List<String> command;
     private File workingDir;
     private long timeout;
-        
+
     public ExternalProcessBuilder handlers(InputHandler input, OutputHandler output, OutputHandler error) {
         this.input = input;
         this.output = output;
         this.error = error;
         return this;
     }
-    
+
     public ExternalProcessBuilder handler(ProcessHandler handler) {
         this.handler = handler;
         return this;
     }
-    
+
     public ExternalProcessBuilder handlers(OutputHandler output, OutputHandler error) {
         return this.handlers(null, output, error);
     }
-    
+
     public ExternalProcessBuilder handlers(OutputHandler output) {
         return this.handlers(null, output, null);
     }
         this.command = command;
         return this;
     }
-    
+
     public ExternalProcessBuilder timeout(long timeout) {
         this.timeout = timeout;
         return this;
     }
-    
+
     public ExternalProcessBuilder log(Logger logger, Priority priority) {
         addMonitor(new LoggingProcessMonitor(logger, priority));
         return this;
         addMonitor(new LoggingProcessMonitor(logger, priority, obfuscator));
         return this;
     }
-    
+
     public ExternalProcessBuilder addMonitor(ProcessMonitor... monitors) {
         if (monitors.length > 0) {
             if (this.monitors == null) {
         }
         return this;
     }
-    
+
     public ExternalProcess build() {
         ProcessHandler h = this.handler;
         if (this.handler == null) {
             } else {
                 plugHandler.setErrorHandler(new StringOutputHandler());
             }
-            
+
             h = plugHandler;
         }
-        
+
         ExternalProcess process = new ExternalProcess(command, handler);
         if (timeout > 0L) {
             process.setTimeout(timeout);
                 }
             }
         }
-        
+
         return process;
     }
 }

processutils/src/main/java/com/atlassian/utils/process/OutputHandler.java

     /**
      * Called when the process completes. This call allows the output handler to close any
      * open resources and finalize any processing.
+     *
+     * @throws ProcessException if there is a problem completing processing
      */
-    void complete();
+    void complete() throws ProcessException;
 
     /**
      * Set the watchdog that this handler should be resetting to prevent the process from being terminated.

processutils/src/main/java/com/atlassian/utils/process/PluggableProcessHandler.java

         this.exitCode = exitCode;
         this.exception = exception;
         if (outputHandler != null) {
-            outputHandler.complete();
+            try {
+                outputHandler.complete();
+            } catch (ProcessException e) {
+                if (this.exception == null) {
+                    this.exception = e;
+                }
+            }
         }
         if (errorHandler != null) {
-            errorHandler.complete();
+            try {
+                errorHandler.complete();
+            } catch (ProcessException e) {
+                if (this.exception == null) {
+                    this.exception = e;
+                }
+            }
         }
         if (inputHandler != null) {
             inputHandler.complete();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.