geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [09/50] [abbrv] incubator-geode git commit: GEODE-1099: NPE thrown from TXManagerImpl.isDistributed()
Date Tue, 29 Mar 2016 22:25:39 GMT
GEODE-1099: NPE thrown from TXManagerImpl.isDistributed()

Use the existing reference to InternalDistributedSystem so as to prevent a NPE.
If the member is indeed being disconnected, a CacheClosed exception is thrown
while trying to send the message.


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

Branch: refs/heads/feature/GEODE-17-3
Commit: 5503de078aa0d45961dc143569651276948ff587
Parents: e22cd95
Author: Swapnil Bawaskar <sbawaskar@pivotal.io>
Authored: Mon Mar 14 17:38:57 2016 -0700
Committer: Swapnil Bawaskar <sbawaskar@pivotal.io>
Committed: Tue Mar 15 12:39:56 2016 -0700

----------------------------------------------------------------------
 .../com/gemstone/gemfire/internal/cache/TXManagerImpl.java    | 3 ++-
 .../gemfire/internal/cache/TXManagerImplJUnitTest.java        | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5503de07/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
index de49fea..7c270fe 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXManagerImpl.java
@@ -1502,7 +1502,8 @@ public final class TXManagerImpl implements CacheTransactionManager,
      Boolean value = isTXDistributed.get();
     // This can be null if not set in setDistributed().
     if (value == null) {
-      return InternalDistributedSystem.getAnyInstance().getOriginalConfig().getDistributedTransactions();
+      InternalDistributedSystem ids = (InternalDistributedSystem) cache.getDistributedSystem();
+      return ids.getOriginalConfig().getDistributedTransactions();
     } else {
       return value.booleanValue();
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5503de07/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
index a92d4dc..0467f4f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/TXManagerImplJUnitTest.java
@@ -331,4 +331,11 @@ public class TXManagerImplJUnitTest {
     assertNull(region.get("key"));
     System.setProperty("gemfire.suspendedTxTimeout", "");
   }
+
+  @Test
+  public void testIsDistributedDoesNotThrowNPE() {
+    TXManagerImpl txMgr = (TXManagerImpl) cache.getCacheTransactionManager();
+    cache.getDistributedSystem().disconnect();
+    assertFalse(txMgr.isDistributed());
+  }
 }


Mime
View raw message