Program: 46908
Project: 46908
Buggy source:
protected void putToCacheAndUpdateFromOtherNodeThenGetUpdatedFromClientNearCache(InMemoryFormat inMemoryFormat){
  NearCacheConfig nearCacheConfig=createNearCacheConfig(inMemoryFormat);
  nearCacheConfig.setInvalidateOnChange(true);
  NearCacheTestContext nearCacheTestContext1=createNearCacheTest(DEFAULT_CACHE_NAME,nearCacheConfig);
  final NearCacheTestContext nearCacheTestContext2=createNearCacheTest(DEFAULT_CACHE_NAME,nearCacheConfig);
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    nearCacheTestContext1.cache.put(i,generateValueFromKey(i));
  }
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    final Integer key=i;
    final String value=nearCacheTestContext2.cache.get(key);
    HazelcastTestSupport.assertTrueEventually(new AssertTask(){
      @Override public void run() throws Exception {
        assertEquals(value,nearCacheTestContext2.nearCache.get(nearCacheTestContext2.serializationService.toData(key)));
      }
    }
);
  }
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    nearCacheTestContext1.cache.put(i,generateValueFromKey(DEFAULT_RECORD_COUNT + i));
  }
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    final int key=i;
    HazelcastTestSupport.assertTrueEventually(new AssertTask(){
      @Override public void run() throws Exception {
        assertNull(nearCacheTestContext2.nearCache.get(nearCacheTestContext2.serializationService.toData(key)));
      }
    }
);
  }
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    final Integer key=i;
    final String value=nearCacheTestContext2.cache.get(key);
    HazelcastTestSupport.assertTrueEventually(new AssertTask(){
      @Override public void run() throws Exception {
        assertEquals(value,nearCacheTestContext2.nearCache.get(nearCacheTestContext2.serializationService.toData(key)));
      }
    }
);
  }
  nearCacheTestContext1.close();
  nearCacheTestContext2.close();
}

Fixed version (ground truth):
protected void putToCacheAndUpdateFromOtherNodeThenGetUpdatedFromClientNearCache(InMemoryFormat inMemoryFormat){
  NearCacheConfig nearCacheConfig=createNearCacheConfig(inMemoryFormat);
  nearCacheConfig.setInvalidateOnChange(true);
  NearCacheTestContext nearCacheTestContext1=createNearCacheTest(DEFAULT_CACHE_NAME,nearCacheConfig);
  final NearCacheTestContext nearCacheTestContext2=createNearCacheTest(DEFAULT_CACHE_NAME,nearCacheConfig);
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    nearCacheTestContext1.cache.put(i,generateValueFromKey(i));
  }
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    final Integer key=i;
    final String value=nearCacheTestContext2.cache.get(key);
    HazelcastTestSupport.assertTrueEventually(new AssertTask(){
      @Override public void run() throws Exception {
        assertEquals(value,nearCacheTestContext2.nearCache.get(nearCacheTestContext2.serializationService.toData(key)));
      }
    }
);
  }
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    nearCacheTestContext1.cache.put(i,generateValueFromKey(DEFAULT_RECORD_COUNT + i));
  }
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    final int key=i;
    HazelcastTestSupport.assertTrueEventually(new AssertTask(){
      @Override public void run() throws Exception {
        assertNull(nearCacheTestContext2.nearCache.get(nearCacheTestContext2.serializationService.toData(key)));
      }
    }
);
  }
  for (int i=0; i < DEFAULT_RECORD_COUNT; i++) {
    final Integer key=i;
    final String value=nearCacheTestContext2.cache.get(key);
    HazelcastTestSupport.assertTrueEventually(new AssertTask(){
      @Override public void run() throws Exception {
        assertEquals(value,nearCacheTestContext2.nearCache.get(nearCacheTestContext2.serializationService.toData(key)));
      }
    }
);
  }
}