Commits

Marcin Gardias committed 6777f22

removing powershell specific code

  • Participants
  • Parent commits 6081cbb

Comments (0)

Files changed (4)

File src/main/java/com/atlassian/utils/process/DefaultExternalProcessFactory.java

         if (settings.hasIdleTimeout()) {
             process.setIdleTimeout(settings.getIdleTimeout());
         }
-        process.setRunWithPowershell(settings.isRunWithPowershell());
     }
 }

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

         
         return this;
     }
-
-    /**
-     * Use powershell instead of cmd.exe to run windows processes. Has no effect if {@link #suppressSpecialWindowsBehaviour()} is used
-     */
-    public ExternalProcessBuilder runWithPowershell()
-    {
-        settings.setRunWithPowershell(true);
-        return this;
-    }
 }

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

     private File workingDir;
     private boolean useWindowsEncodingWorkaround;
 
-    private boolean runWithPowershell;
-
     /**
      * Process an external command.
      *
         this.useWindowsEncodingWorkaround = useWindowsEncodingWorkaround;
     }
 
-    public void setRunWithPowershell(final boolean runWithPowershell)
-    {
-        this.runWithPowershell = runWithPowershell;
-    }
-
     private boolean areOutputPumpsRunning() {
         return (outputPump != null && outputPump.isRunning()) || (errorPump != null && errorPump.isRunning());
     }
             throws IOException {
         List<String> newCommand = new ArrayList<String>(command.size() + 4);
 
-        if (runWithPowershell)
-        {
-            newCommand.add("powershell");
-            newCommand.add("-Command");
-        }
-        else
-        {
-            newCommand.add("cmd");
-            newCommand.add("/A"); // use ANSI encoding
-            newCommand.add("/C");
-            newCommand.add("call");
-        }
+        newCommand.add("cmd");
+        newCommand.add("/A"); // use ANSI encoding
+        newCommand.add("/C");
+        newCommand.add("call");
 
         if (useWindowsEncodingWorkaround) {
             newCommand.add(command.get(0));
                 protected void doTask() {
                     try {
                         handler.provideInput(process.getOutputStream());
-                        if (runWithPowershell)
-                        {
-                            process.getOutputStream().close();
-                        }
                     } catch (Throwable t) {
                         // The StdInHandler IO pump is intentionally interrupted when the process terminates, the output and the
                         // error pumps have finished and the StdInHandler does not finish by itself. In this case we do not
                         if (!shouldIgnoreInputPumpException(t)) {
                             handleHandlerError(name, t);
                         }
+                    } finally {
+                        try {
+                            process.getOutputStream().close();
+                        } catch (IOException e) {
+                            ExternalProcessImpl.LOG.error("Error closing output stream", e);
+                        }
                     }
                 }
             };
         }
-        else if (runWithPowershell)
+        else
         {
             try
             {
             }
             catch (IOException ioe)
             {
-                //hmm....
+                ExternalProcessImpl.LOG.error("Error closing output stream", ioe);
             }
         }
 

File src/main/java/com/atlassian/utils/process/ExternalProcessSettings.java

     private boolean useWindowsEncodingWorkaround;
     private File workingDirectory;
 
-    private boolean runWithPowershell;
-
     public ExternalProcessSettings() {
         environment = new HashMap<String, String>();
         monitors = new ArrayList<ProcessMonitor>();
             throw new IllegalStateException("A ProcessHandler is required");
         }
     }
-
-    public boolean isRunWithPowershell()
-    {
-        return runWithPowershell;
-    }
-
-    public void setRunWithPowershell(final boolean runWithPowershell)
-    {
-        this.runWithPowershell = runWithPowershell;
-    }
 }