@Test
  public void verifyNoProcessingReplyFromADepartedMember() {
    SearchLoadAndWriteProcessor processor = SearchLoadAndWriteProcessor.getProcessor();
    DistributedRegion lr = mock(DistributedRegion.class);
    RegionAttributes attrs = mock(RegionAttributes.class);
    GemFireCacheImpl cache = mock(GemFireCacheImpl.class);
    InternalDistributedSystem ds = mock(InternalDistributedSystem.class);
    DistributionManager dm = mock(DistributionManager.class);
    CacheDistributionAdvisor advisor = mock(CacheDistributionAdvisor.class);
    CachePerfStats stats = mock(CachePerfStats.class);
    ExpirationAttributes expirationAttrs = mock(ExpirationAttributes.class);
    InternalDistributedMember m1 = mock(InternalDistributedMember.class);
    InternalDistributedMember m2 = mock(InternalDistributedMember.class);
    Set<InternalDistributedMember> replicates = new HashSet<>();
    replicates.add(m1);
    replicates.add(m2);

    when(lr.getAttributes()).thenReturn(attrs);
    when(lr.getSystem()).thenReturn(ds);
    when(lr.getCache()).thenReturn(cache);
    when(lr.getCacheDistributionAdvisor()).thenReturn(advisor);
    when(lr.getDistributionManager()).thenReturn(dm);
    when(lr.getCachePerfStats()).thenReturn(stats);
    when(lr.getScope()).thenReturn(Scope.DISTRIBUTED_ACK);
    when(lr.getCancelCriterion()).thenReturn(mock(CancelCriterion.class));
    when(cache.getDistributedSystem()).thenReturn(ds);
    when(cache.getInternalDistributedSystem()).thenReturn(ds);
    when(cache.getSearchTimeout()).thenReturn(30);
    when(attrs.getScope()).thenReturn(Scope.DISTRIBUTED_ACK);
    when(attrs.getDataPolicy()).thenReturn(DataPolicy.EMPTY);
    when(attrs.getEntryTimeToLive()).thenReturn(expirationAttrs);
    when(attrs.getEntryIdleTimeout()).thenReturn(expirationAttrs);
    when(advisor.adviseInitializedReplicates()).thenReturn(replicates);

    Object key = "k1";
    byte[] v1 = "v1".getBytes();
    byte[] v2 = "v2".getBytes();
    EntryEventImpl event = EntryEventImpl.create(lr, Operation.GET, key, null, null, false, null);


    Thread t1 = new Thread(() -> {
      await()
          .until(() -> processor.getSelectedNode() != null);
      departedMember = processor.getSelectedNode();
      // Simulate member departed event
      processor.memberDeparted(dm, departedMember, true);
    });
    t1.start();

    Thread t2 = new Thread(() -> {
      await()
          .until(() -> departedMember != null && processor.getSelectedNode() != null
              && departedMember != processor.getSelectedNode());

      // Handle search result from the departed member
      processor.incomingNetSearchReply(v1, System.currentTimeMillis(), false, false, true,
          mock(VersionTag.class), departedMember);
    });
    t2.start();

    Thread t3 = new Thread(() -> {
      await()
          .until(() -> departedMember != null && processor.getSelectedNode() != null
              && departedMember != processor.getSelectedNode());
      // Handle search result from a new member
      processor.incomingNetSearchReply(v2, System.currentTimeMillis(), false, false, true,
          mock(VersionTag.class), processor.getSelectedNode());
    });
    t3.start();

    processor.initialize(lr, key, null);
    processor.doSearchAndLoad(event, null, null, false);

    assertTrue(Arrays.equals((byte[]) event.getNewValue(), v2));
  }
This test verifies the fix for GEODE-1199. It verifies that when doNetWrite is called with an
event that has a StoredObject value that it will have "release" called on it.
geode-core/src/test/java/org/apache/geode/internal/cache/SearchLoadAndWriteProcessorTest.java