Program: 46023
Project: 46023
Buggy source:
protected Object getInternal(final K key,ExpiryPolicy expiryPolicy,boolean async){
  final long start=System.nanoTime();
  ensureOpen();
  validateNotNull(key);
  final Data keyData=toData(key);
  Object cached=getCachedValue(keyData,!async);
  if (cached != NOT_CACHED) {
    return asCompletedFutureOrValue(cached,async);
  }
  final long reservationId=tryReserveForUpdate(keyData);
  final Data expiryPolicyData=toData(expiryPolicy);
  ClientMessage request=CacheGetCodec.encodeRequest(nameWithPrefix,keyData,expiryPolicyData);
  ClientInvocationFuture future;
  try {
    final int partitionId=clientContext.getPartitionService().getPartitionId(keyData);
    final HazelcastClientInstanceImpl client=(HazelcastClientInstanceImpl)clientContext.getHazelcastInstance();
    final ClientInvocation clientInvocation=new ClientInvocation(client,request,partitionId);
    future=clientInvocation.invoke();
  }
 catch (  Throwable t) {
    invalidateNearCache(keyData);
    throw rethrow(t);
  }
  SerializationService serializationService=clientContext.getSerializationService();
  ClientDelegatingFuture<V> delegatingFuture=new ClientDelegatingFuture<V>(future,serializationService,cacheGetResponseDecoder);
  if (async) {
    if (nearCache != null) {
      delegatingFuture.andThenInternal(new ExecutionCallback<Data>(){
        public void onResponse(        Data valueData){
          storeInNearCache(keyData,valueData,null,reservationId,false);
          if (statisticsEnabled) {
            handleStatisticsOnGet(start,valueData);
          }
        }
        public void onFailure(        Throwable t){
          invalidateNearCache(keyData);
        }
      }
,false);
    }
    return delegatingFuture;
  }
 else {
    try {
      V value=toObject(delegatingFuture.get());
      if (nearCache != null) {
        storeInNearCache(keyData,(Data)delegatingFuture.getResponse(),value,reservationId,false);
      }
      if (statisticsEnabled) {
        handleStatisticsOnGet(start,value);
      }
      return value;
    }
 catch (    Throwable e) {
      invalidateNearCache(keyData);
      throw rethrowAllowedTypeFirst(e,CacheException.class);
    }
  }
}

Fixed version (ground truth):
protected Object getInternal(final K key,ExpiryPolicy expiryPolicy,boolean async){
  final long start=System.nanoTime();
  ensureOpen();
  validateNotNull(key);
  final Data keyData=toData(key);
  Object cached=getCachedValue(keyData,!async);
  if (cached != NOT_CACHED) {
    return asCompletedFutureOrValue(cached,async);
  }
  final long reservationId=tryReserveForUpdate(keyData);
  final Data expiryPolicyData=toData(expiryPolicy);
  ClientMessage request=CacheGetCodec.encodeRequest(nameWithPrefix,keyData,expiryPolicyData);
  ClientInvocationFuture future;
  try {
    final int partitionId=clientContext.getPartitionService().getPartitionId(keyData);
    final HazelcastClientInstanceImpl client=(HazelcastClientInstanceImpl)clientContext.getHazelcastInstance();
    final ClientInvocation clientInvocation=new ClientInvocation(client,request,partitionId);
    future=clientInvocation.invoke();
  }
 catch (  Throwable t) {
    invalidateNearCache(keyData);
    throw rethrow(t);
  }
  SerializationService serializationService=clientContext.getSerializationService();
  ClientDelegatingFuture<V> delegatingFuture=new ClientDelegatingFuture<V>(future,serializationService,cacheGetResponseDecoder);
  if (async) {
    if (nearCache != null) {
      delegatingFuture.andThenInternal(new ExecutionCallback<Data>(){
        public void onResponse(        Data valueData){
          storeInNearCache(keyData,valueData,null,reservationId,false);
          if (statisticsEnabled) {
            handleStatisticsOnGet(start,valueData);
          }
        }
        public void onFailure(        Throwable t){
          invalidateNearCache(keyData);
        }
      }
,false);
    }
    return delegatingFuture;
  }
 else {
    try {
      V value=delegatingFuture.get();
      if (nearCache != null) {
        storeInNearCache(keyData,(Data)delegatingFuture.getRaw(),value,reservationId,false);
      }
      if (statisticsEnabled) {
        handleStatisticsOnGet(start,value);
      }
      return value;
    }
 catch (    Throwable e) {
      invalidateNearCache(keyData);
      throw rethrowAllowedTypeFirst(e,CacheException.class);
    }
  }
}