RegionMapPut extends AbstractRegionMapPut { @Override protected void runWhileLockedForCacheModification(Runnable r) { cacheModificationLock.lockForCacheModification(getOwner(), getEvent()); try { super.runWhileLockedForCacheModification(r); } finally { cacheModificationLock.releaseCacheModificationLock(getOwner(), getEvent()); } } RegionMapPut(FocusedRegionMap focusedRegionMap, InternalRegion owner,
      CacheModificationLock cacheModificationLock, EntryEventSerialization entryEventSerialization,
      EntryEventImpl event, boolean ifNew, boolean ifOld, boolean overwriteDestroyed,
      boolean requireOldValue, Object expectedOldValue);   }
@Test public void runWileLockedForCacheModificationDoesNotLockGIIClearLockWhenRegionIsInitialized() throws Exception { DistributedRegion region = mock(DistributedRegion.class); when(region.isInitialized()).thenReturn(true); when(region.lockWhenRegionIsInitializing()).thenCallRealMethod(); RegionMapPut regionMapPut = new RegionMapPut(focusedRegionMap, region, cacheModificationLock, entryEventSerialization, event, ifNew, ifOld, overwriteDestroyed, requireOldValue, expectedOldValue); regionMapPut.runWhileLockedForCacheModification(() -> { }); verify(region).lockWhenRegionIsInitializing(); assertThat(region.lockWhenRegionIsInitializing()).isFalse(); verify(region, never()).unlockWhenRegionIsInitializing(); }
@Test public void runWileLockedForCacheModificationLockGIIClearLockWhenRegionIsInitializing() { DistributedRegion region = mock(DistributedRegion.class); when(region.isInitialized()).thenReturn(false); when(region.lockWhenRegionIsInitializing()).thenCallRealMethod(); RegionMapPut regionMapPut = new RegionMapPut(focusedRegionMap, region, cacheModificationLock, entryEventSerialization, event, ifNew, ifOld, overwriteDestroyed, requireOldValue, expectedOldValue); regionMapPut.runWhileLockedForCacheModification(() -> { }); verify(region).lockWhenRegionIsInitializing(); assertThat(region.lockWhenRegionIsInitializing()).isTrue(); verify(region).unlockWhenRegionIsInitializing(); }