Repository: incubator-geode
Updated Branches:
  refs/heads/develop 6dc2f5753 -> 00de1b0f6


GEODE-857: Fix data race in SystemFailureJUnit

The SystemFailure class was storing state in a static var without
ensuring thread-safe reads and writes. This was causing intermittent
test failures. Fixed the data race and set the flag correctly as a
test precondition.


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

Branch: refs/heads/develop
Commit: 00de1b0f6aeed11bfafcc3461869f44c6d7c883b
Parents: 6dc2f57
Author: Anthony Baker <[email protected]>
Authored: Tue Mar 22 20:08:12 2016 -0700
Committer: Anthony Baker <[email protected]>
Committed: Wed Mar 23 09:54:10 2016 -0700

----------------------------------------------------------------------
 geode-core/src/main/java/com/gemstone/gemfire/SystemFailure.java   | 2 +-
 .../src/test/java/com/gemstone/gemfire/SystemFailureJUnitTest.java | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/00de1b0f/geode-core/src/main/java/com/gemstone/gemfire/SystemFailure.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/SystemFailure.java 
b/geode-core/src/main/java/com/gemstone/gemfire/SystemFailure.java
index 1775063..2b214c8 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/SystemFailure.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/SystemFailure.java
@@ -344,7 +344,7 @@ public final class SystemFailure {
    */
   private static Thread watchDog;
   
-  private static boolean isCacheClosing = false;
+  private static volatile boolean isCacheClosing = false;
 
   /**
    * Should be invoked when GemFire cache is being created. 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/00de1b0f/geode-core/src/test/java/com/gemstone/gemfire/SystemFailureJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/com/gemstone/gemfire/SystemFailureJUnitTest.java 
b/geode-core/src/test/java/com/gemstone/gemfire/SystemFailureJUnitTest.java
index c5efaf0..b138e7f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/SystemFailureJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/SystemFailureJUnitTest.java
@@ -45,6 +45,7 @@ public class SystemFailureJUnitTest {
   }
   @Test
   public void testStopThreads() {
+    SystemFailure.signalCacheCreate();
     SystemFailure.startThreads();
     long start = System.nanoTime();
     Thread watchDog = SystemFailure.getWatchDogForTest();

Reply via email to