Commits

James Dumay committed e7078fd

Use latest winp from hudson

  • Participants
  • Parent commits 1d16b69

Comments (0)

Files changed (3)

     <dependency>
       <groupId>org.jvnet.winp</groupId>
       <artifactId>winp</artifactId>
-      <version>1.9</version>
+      <version>1.14</version>
     </dependency>
 
     <dependency>

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

  * the process' IO requirements.
  */
 public class ExternalProcess implements Watchdog {
+    private static final Logger log = Logger.getLogger(ExternalProcess.class);
     private static final String OS_NAME = System.getProperty("os.name");
     
     private boolean useWindowsEncodingWorkaround = false;
 
         if (OS_NAME.startsWith("Windows"))
         {
-            final WinProcess winProcess = new WinProcess(process);
-            winProcess.killRecursively();
+            try
+            {
+                final WinProcess winProcess = new WinProcess(process);
+                winProcess.killRecursively();
+            }
+            catch (UnsatisfiedLinkError e)
+            {
+                log.error("Could not recursively kill windows process using winp; falling back to java.lang.Process#destroy", e);
+                process.destroy();
+            }
         }
         else
         {

src/test/java/com/atlassian/utils/process/ExternalProcessTest.java

         EchoResult result = spawnEcho("iso-8859-1", "iso-8859-1");
         assertEquals("ISO-8859-1 - incompatibility detected:", result.input, result.output);
     }
+
+    @Test
+    public void testNativeWindowsKilling()
+    {
+        ExternalProcess process = new ExternalProcessBuilder().command(Arrays.asList("pause")).build();
+        process.start();
+        process.cancel();
+        assertNotNull(process.getHandler().getException());
+    }
 }