geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject incubator-geode git commit: [GEODE-329] fix ShutdownAllDUnitTest failure
Date Tue, 22 Sep 2015 17:06:06 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-329 [created] 1ff59f744


[GEODE-329] fix ShutdownAllDUnitTest failure

There's a race condition that there will be 2 distributed systems are
created in one JVM.

When a DS is disconnecting, the current thread stays in wait(500) and
release the lock. Thread2 comes and found a disconnected DS, so it will
create a new DS. When the current thread waked up, it should double check
if the DS has been changed.


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

Branch: refs/heads/feature/GEODE-329
Commit: 1ff59f7440709c11b5f09d11ed08190e225cc8e3
Parents: 4708d4e
Author: zhouxh <gzhou@pivotal.io>
Authored: Mon Sep 21 14:56:17 2015 -0700
Committer: zhouxh <gzhou@pivotal.io>
Committed: Mon Sep 21 14:56:17 2015 -0700

----------------------------------------------------------------------
 .../gemfire/distributed/DistributedSystem.java  | 48 +++++++++++---------
 1 file changed, 26 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1ff59f74/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
index b7b2cd8..312d283 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
@@ -1584,34 +1584,38 @@ public abstract class DistributedSystem implements StatisticsFactory
{
         }
 
       } else {
-        if (!existingSystems.isEmpty()) {
-          Assert.assertTrue(existingSystems.size() == 1);
+        boolean existingSystemDisconnected = false;
+        do {
+          if (!existingSystems.isEmpty()) {
+            Assert.assertTrue(existingSystems.size() == 1);
 
-          InternalDistributedSystem existingSystem =
-            (InternalDistributedSystem) existingSystems.get(0);
-          if (existingSystem.isDisconnecting()) {
-            while (existingSystem.isConnected()) {
-              boolean interrupted = Thread.interrupted();
-              try {
-                existingSystemsLock.wait(500);
-              } 
-              catch (InterruptedException ex) {
-                interrupted = true;
-              }
-              finally {
-                if (interrupted) {
-                  Thread.currentThread().interrupt();
+            InternalDistributedSystem existingSystem =
+                (InternalDistributedSystem) existingSystems.get(0);
+            if (existingSystem.isDisconnecting()) {
+              while (existingSystem.isConnected()) {
+                boolean interrupted = Thread.interrupted();
+                try {
+                  existingSystemsLock.wait(500);
+                } 
+                catch (InterruptedException ex) {
+                  interrupted = true;
+                }
+                finally {
+                  if (interrupted) {
+                    Thread.currentThread().interrupt();
+                  }
                 }
               }
+              existingSystemDisconnected = true;
             }
-          }
 
-          if (existingSystem.isConnected()) {
-            existingSystem.validateSameProperties(config,
-                existingSystem.isConnected());
-            return existingSystem;
+            if (existingSystem.isConnected()) {
+              existingSystem.validateSameProperties(config,
+                  existingSystem.isConnected());
+              return existingSystem;
+            }
           }
-        }
+        } while (existingSystemDisconnected);
       }
 
       // Make a new connection to the distributed system


Mime
View raw message