You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2018/12/05 19:09:42 UTC

[geode] branch feature/GEODE-6149 created (now b13401c)

This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a change to branch feature/GEODE-6149
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at b13401c  GEODE-6149: when client's cache is closing, its GetClientPRMetaDataOp could end up with NPE

This branch includes the following new commits:

     new b13401c  GEODE-6149: when client's cache is closing, its GetClientPRMetaDataOp could end up with NPE

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[geode] 01/01: GEODE-6149: when client's cache is closing, its GetClientPRMetaDataOp could end up with NPE

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a commit to branch feature/GEODE-6149
in repository https://gitbox.apache.org/repos/asf/geode.git

commit b13401c12ae53cc8356ba8f051eb10124d4680af
Author: zhouxh <gz...@pivotal.io>
AuthorDate: Wed Dec 5 11:08:32 2018 -0800

    GEODE-6149: when client's cache is closing, its GetClientPRMetaDataOp could end up with NPE
---
 .../client/internal/GetClientPRMetaDataOp.java     |  5 ++++
 .../internal/GetClientPRMetaDataOpJUnitTest.java   | 32 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/GetClientPRMetaDataOp.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/GetClientPRMetaDataOp.java
index c82860d..5b676a0 100755
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/GetClientPRMetaDataOp.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/GetClientPRMetaDataOp.java
@@ -95,6 +95,11 @@ public class GetClientPRMetaDataOp {
           }
           int numParts = msg.getNumberOfParts();
           ClientPartitionAdvisor advisor = cms.getClientPartitionAdvisor(regionFullPath);
+          if (advisor == null) {
+            logger.debug(
+                "GetClientPRMetaDataOpImpl#processResponse: advisor is null, which could be due to cache is closed. Not to update PR meta data.");
+            return null;
+          }
           for (int i = 0; i < numParts; i++) {
             Object result = msg.getPart(i).getObject();
             List<BucketServerLocation66> locations = (List<BucketServerLocation66>) result;
diff --git a/geode-core/src/test/java/org/apache/geode/cache/client/internal/GetClientPRMetaDataOpJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/client/internal/GetClientPRMetaDataOpJUnitTest.java
new file mode 100644
index 0000000..535d794
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/cache/client/internal/GetClientPRMetaDataOpJUnitTest.java
@@ -0,0 +1,32 @@
+package org.apache.geode.cache.client.internal;
+
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.internal.cache.tier.MessageType;
+import org.apache.geode.internal.cache.tier.sockets.Message;
+
+public class GetClientPRMetaDataOpJUnitTest {
+  @Test
+  public void processResponseWhenCacheClosedShuouldReturnNull() throws Exception {
+    Cache cache = mock(Cache.class);
+    ClientMetadataService cms = new ClientMetadataService(cache);
+    cms = spy(cms);
+    doReturn(true).when(cache).isClosed();
+
+    Message msg = mock(Message.class);
+    GetClientPRMetaDataOp.GetClientPRMetaDataOpImpl op =
+        new GetClientPRMetaDataOp.GetClientPRMetaDataOpImpl("testRegion", cms);
+    op = spy(op);
+
+    when(msg.getMessageType()).thenReturn(MessageType.RESPONSE_CLIENT_PR_METADATA);
+
+    assertNull(op.processResponse(msg));
+  }
+}