Source:
<code>public void testEntryNotWrapped() throws Throwable { assertClusterSize("Wrong cluster size!", 3); final Object key = new MagicKey(cache(0), cache(1)); final Cache<Object, Object> futureBackupOwnerCache = cache(2); cache(0).put(key, INITIAL_VALUE); final PerCacheInboundInvocationHandler spyHandler = spyInvocationHandler(futureBackupOwnerCache); final EntryFactory spyEntryFactory = spyEntryFactory(futureBackupOwnerCache); final CountDownLatch latch1 = new CountDownLatch(1); final CountDownLatch latch2 = new CountDownLatch(1); doAnswer(invocation -> { CacheRpcCommand command = (CacheRpcCommand) invocation.getArguments()[0]; if (command instanceof StateResponseCommand) { log.debugf("Blocking command %s", command); latch2.countDown(); latch1.await(); } return invocation.callRealMethod(); }).when(spyHandler).handle(any(CacheRpcCommand.class), any(Reply.class), any(DeliverOrder.class)); doAnswer(invocation -> { InvocationContext context = (InvocationContext) invocation.getArguments()[0]; log.debugf("wrapEntryForWriting invoked with %s", context); Object mvccEntry = invocation.callRealMethod(); <START> assertNull(context.lookupEntry(key), "Entry should not be wrapped!"); <END> return mvccEntry; }).when(spyEntryFactory).wrapEntryForWriting(any(InvocationContext.class), any(), anyInt(), anyBoolean(), anyBoolean()); Future<?> killMemberResult = fork(() -> killMember(1)); latch2.await(30, TimeUnit.SECONDS); futureBackupOwnerCache.put(key, FINAL_VALUE); latch1.countDown(); killMemberResult.get(30, TimeUnit.SECONDS); }</code><technical_language>If instance of NullCacheEntry now, assert that</technical_language>

Target:
public void testEntryNotWrapped() throws Throwable { assertClusterSize("Wrong cluster size!", 3); final Object key = new MagicKey(cache(0), cache(1)); final Cache<Object, Object> futureBackupOwnerCache = cache(2); cache(0).put(key, INITIAL_VALUE); final PerCacheInboundInvocationHandler spyHandler = spyInvocationHandler(futureBackupOwnerCache); final EntryFactory spyEntryFactory = spyEntryFactory(futureBackupOwnerCache); final CountDownLatch latch1 = new CountDownLatch(1); final CountDownLatch latch2 = new CountDownLatch(1); doAnswer(invocation -> { CacheRpcCommand command = (CacheRpcCommand) invocation.getArguments()[0]; if (command instanceof StateResponseCommand) { log.debugf("Blocking command %s", command); latch2.countDown(); latch1.await(); } return invocation.callRealMethod(); }).when(spyHandler).handle(any(CacheRpcCommand.class), any(Reply.class), any(DeliverOrder.class)); doAnswer(invocation -> { InvocationContext context = (InvocationContext) invocation.getArguments()[0]; log.debugf("wrapEntryForWriting invoked with %s", context); CompletionStage<Void> stage = (CompletionStage<Void>) invocation.callRealMethod(); CompletionStages.join(stage); assertNull(context.lookupEntry(key), "Entry should not be wrapped!"); return stage; }).when(spyEntryFactory).wrapEntryForWriting(any(InvocationContext.class), any(), anyInt(), anyBoolean(), anyBoolean()); Future<?> killMemberResult = fork(() -> killMember(1)); latch2.await(30, TimeUnit.SECONDS); futureBackupOwnerCache.put(key, FINAL_VALUE); latch1.countDown(); killMemberResult.get(30, TimeUnit.SECONDS); }