geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject incubator-geode git commit: GEODE-103: fix usage of isProcessAlive to remove race condition
Date Mon, 04 Apr 2016 22:10:04 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 2deb31d95 -> 066a9d57a


GEODE-103: fix usage of isProcessAlive to remove race condition

* also fixes GEODE-1136


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/066a9d57
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/066a9d57
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/066a9d57

Branch: refs/heads/develop
Commit: 066a9d57a165527b20b4e64e8633676416ef834c
Parents: 2deb31d
Author: Kirk Lund <klund@pivotal.io>
Authored: Mon Apr 4 12:44:54 2016 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Mon Apr 4 12:45:57 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/process/ProcessUtils.java  |  9 ++------
 .../BlockingProcessStreamReaderJUnitTest.java   | 16 -------------
 ...NonBlockingProcessStreamReaderJUnitTest.java | 24 --------------------
 3 files changed, 2 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/066a9d57/geode-core/src/main/java/com/gemstone/gemfire/internal/process/ProcessUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/process/ProcessUtils.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/process/ProcessUtils.java
index c2841da..db99615 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/process/ProcessUtils.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/process/ProcessUtils.java
@@ -85,14 +85,9 @@ public final class ProcessUtils {
    * @return true if the Process is a currently running process
    */
   public static boolean isProcessAlive(final Process process) {
-    try {
-      process.exitValue();
-      return false;
-    } catch (IllegalThreadStateException e) {
-      return true;
-    }
+    return process.isAlive();
   }
-  
+
   /**
    * Returns true if a process identified by the process id was
    * running on this host machine and has been terminated by this operation.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/066a9d57/geode-core/src/test/java/com/gemstone/gemfire/internal/process/BlockingProcessStreamReaderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/BlockingProcessStreamReaderJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/BlockingProcessStreamReaderJUnitTest.java
index d83d9fe..53c78c7 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/BlockingProcessStreamReaderJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/BlockingProcessStreamReaderJUnitTest.java
@@ -283,14 +283,6 @@ public class BlockingProcessStreamReaderJUnitTest extends ProcessStreamReaderTes
     this.stderr.start();
     this.stdout.start();
     
-    // wait for process to start
-    assertEventuallyTrue("Process never started", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        return ProcessUtils.isProcessAlive(process);
-      }
-    }, WAIT_FOR_PROCESS_TO_START_TIMEOUT, INTERVAL);
-    
     // wait for process to die
     assertEventuallyFalse("Process never died", new Callable<Boolean>() {
       @Override
@@ -363,14 +355,6 @@ public class BlockingProcessStreamReaderJUnitTest extends ProcessStreamReaderTes
     this.stderr.start();
     this.stdout.start();
     
-    // wait for process to start
-    assertEventuallyTrue("Process never started", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        return ProcessUtils.isProcessAlive(process);
-      }
-    }, WAIT_FOR_PROCESS_TO_START_TIMEOUT, INTERVAL);
-    
     // wait for process to die
     assertEventuallyFalse("Process never died", new Callable<Boolean>() {
       @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/066a9d57/geode-core/src/test/java/com/gemstone/gemfire/internal/process/NonBlockingProcessStreamReaderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/NonBlockingProcessStreamReaderJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/NonBlockingProcessStreamReaderJUnitTest.java
index ca8f1a5..2960190 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/NonBlockingProcessStreamReaderJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/NonBlockingProcessStreamReaderJUnitTest.java
@@ -140,14 +140,6 @@ public class NonBlockingProcessStreamReaderJUnitTest extends ProcessStreamReader
     this.stderr.start();
     this.stdout.start();
     
-    // wait for process to start
-    assertEventuallyTrue("Process never started", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        return ProcessUtils.isProcessAlive(process);
-      }
-    }, WAIT_FOR_PROCESS_TO_START_TIMEOUT, INTERVAL);
-    
     // wait for process to die
     assertEventuallyFalse("Process never died", new Callable<Boolean>() {
       @Override
@@ -218,14 +210,6 @@ public class NonBlockingProcessStreamReaderJUnitTest extends ProcessStreamReader
     this.stderr.start();
     this.stdout.start();
     
-    // wait for process to start
-    assertEventuallyTrue("Process never started", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        return ProcessUtils.isProcessAlive(process);
-      }
-    }, WAIT_FOR_PROCESS_TO_START_TIMEOUT, INTERVAL);
-    
     // wait for process to die
     assertEventuallyFalse("Process never died", new Callable<Boolean>() {
       @Override
@@ -296,14 +280,6 @@ public class NonBlockingProcessStreamReaderJUnitTest extends ProcessStreamReader
     this.stderr.start();
     this.stdout.start();
     
-    // wait for process to start
-    assertEventuallyTrue("Process never started", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        return ProcessUtils.isProcessAlive(process);
-      }
-    }, WAIT_FOR_PROCESS_TO_START_TIMEOUT, INTERVAL);
-    
     // wait for process to die
     assertEventuallyFalse("Process never died", new Callable<Boolean>() {
       @Override


Mime
View raw message