gesterzhou commented on a change in pull request #6964:
URL: https://github.com/apache/geode/pull/6964#discussion_r727507486



##########
File path: 
geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTest.java
##########
@@ -443,6 +449,38 @@ public void 
generatePRIdShouldNotThrowNumberFormatExceptionIfAnErrorOccursWhileR
         .doesNotThrowAnyException();
   }
 
+  @Test
+  public void 
registerPartitionedRegionShouldHandleLockServiceDestroyedException()
+      throws ClassNotFoundException {
+    AttributesFactory attributesFactory = new AttributesFactory();
+    attributesFactory.setPartitionAttributes(
+        new 
PartitionAttributesFactory().setTotalNumBuckets(1).setRedundantCopies(1)
+            .setLocalMaxMemory(0).create());
+
+    partitionedRegion = new PartitionedRegion("region", 
attributesFactory.create(), null, cache,
+        mock(InternalRegionArguments.class), disabledClock(), 
ColocationLoggerFactory.create());
+
+    PartitionedRegion spyPartitionedRegion = spy(partitionedRegion);
+
+    InternalDistributedMember imageTarget = 
mock(InternalDistributedMember.class);
+    InternalRegionFactory factory = mock(InternalRegionFactory.class);
+    
when(cache.createInternalRegionFactory(RegionShortcut.REPLICATE)).thenReturn(factory);
+    DistributedRegion partitionedRegionRoot = mock(DistributedRegion.class);
+    
when(factory.create(PR_ROOT_REGION_NAME)).thenReturn(partitionedRegionRoot);
+    CacheDistributionAdvisor cda = mock(CacheDistributionAdvisor.class);
+    doNothing().when(cda).addMembershipListener(any());
+    when(partitionedRegionRoot.getDistributionAdvisor()).thenReturn(cda);
+    PartitionedRegion.RegionLock regionLock = 
mock(PartitionedRegion.RegionLock.class);
+    doReturn(regionLock).when(spyPartitionedRegion).getRegionLock();
+    doThrow(new LockServiceDestroyedException("Lock Service is destroyed in 
test")).when(regionLock)
+        .lock();
+    doThrow(new 
DistributedSystemDisconnectedException("test")).when(spyPartitionedRegion)
+        .cleanupFailedInitialization();
+    assertThatThrownBy(() -> spyPartitionedRegion.initialize(null, 
imageTarget, null))
+        .isInstanceOf(PartitionedRegionException.class)
+        .hasCauseInstanceOf(DistributedSystemDisconnectedException.class);
+  }
+

Review comment:
       fixed

##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
##########
@@ -5602,6 +5625,12 @@ public void cleanupFailedInitialization() {
     if (logger.isDebugEnabled()) {
       logger.debug("cleanupFailedInitialization: end of {}", getName());
     }
+    if (savedFirstRuntimeException != null
+        && savedFirstRuntimeException instanceof 
DistributedSystemDisconnectedException) {
+      logger.warn("cleanupFailedInitialization originally failed with ",
+          savedFirstRuntimeException);

Review comment:
       fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to