Program: 46145
Project: 46145
Buggy source:
protected Object getInternal(K key,ExpiryPolicy expiryPolicy,boolean async){
  final long start=System.nanoTime();
  ensureOpen();
  validateNotNull(key);
  final Data keyData=toData(key);
  Object cached=getFromNearCache(keyData,async);
  if (cached != null) {
    return cached;
  }
  final boolean marked=keyStateMarker.markIfUnmarked(keyData);
  final Data expiryPolicyData=toData(expiryPolicy);
  ClientMessage request=CacheGetCodec.encodeRequest(nameWithPrefix,keyData,expiryPolicyData);
  ClientInvocationFuture future;
  try {
    final int partitionId=clientContext.getPartitionService().getPartitionId(key);
    final HazelcastClientInstanceImpl client=(HazelcastClientInstanceImpl)clientContext.getHazelcastInstance();
    final ClientInvocation clientInvocation=new ClientInvocation(client,request,partitionId);
    future=clientInvocation.invoke();
  }
 catch (  Exception e) {
    resetToUnmarkedState(keyData);
    throw rethrow(e);
  }
  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,marked);
          if (statisticsEnabled) {
            handleStatisticsOnGet(start,valueData);
          }
        }
        public void onFailure(        Throwable t){
          resetToUnmarkedState(keyData);
        }
      }
);
    }
    return delegatingFuture;
  }
 else {
    try {
      Object value=toObject(delegatingFuture.get());
      if (nearCache != null) {
        storeInNearCache(keyData,(Data)delegatingFuture.getResponse(),(V)value,marked);
      }
      if (statisticsEnabled) {
        handleStatisticsOnGet(start,value);
      }
      return value;
    }
 catch (    Throwable e) {
      resetToUnmarkedState(keyData);
      throw ExceptionUtil.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(key);
    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);
        }
      }
);
    }
    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);
    }
  }
}