Program: 93862
Project: 93862
Buggy source:
public Future<V> getWithLoaderAsync(final K key,final CacheLoader<K,V> loader){
  if (key == null)   throw new NullPointerException();
  if (executorService == null || executorService.isShutdown() || closed)   throw new IllegalStateException("String_Node_Str");
  final KeyBuffer keySource=keySource(key);
  final OffHeapMap segment=segment(keySource.hash());
  long hashEntryAdr=segment.getEntry(keySource,true);
  if (hashEntryAdr == 0L) {
    final long keyLen=keySerializer.serializedSize(key);
    long bytes=Util.allocLen(keyLen,0L);
    if ((maxEntrySize > 0L && bytes > maxEntrySize) || (hashEntryAdr=Uns.allocate(bytes,throwOOME)) == 0L) {
      putFailCount++;
      remove(key);
      return Futures.immediateFailedFuture(new RuntimeException("String_Node_Str"));
    }
    final HashEntryKeyOutput keyOut=new HashEntryKeyOutput(hashEntryAdr,keyLen);
    try {
      keySerializer.serialize(key,keyOut);
    }
 catch (    Throwable e) {
      freeAndThrow(e,hashEntryAdr);
    }
    final long hash=keyOut.hash(hasher);
    HashEntries.init(hash,keyLen,0L,hashEntryAdr,Util.SENTINEL_LOADING);
    if (segment.putEntry(hashEntryAdr,hash,keyLen,bytes,true,0L,0L)) {
      final long sentinelHashEntryAdr=hashEntryAdr;
      return executorService.submit(new Callable<V>(){
        public V call() throws Exception {
          Exception failure=null;
          V value=null;
          boolean replaced=false;
          try {
            value=loader.load(key);
            long valueLen=valueSerializer.serializedSize(value);
            long bytes=Util.allocLen(keyLen,valueLen);
            long hashEntryAdr;
            if ((maxEntrySize > 0L && bytes > maxEntrySize) || (hashEntryAdr=Uns.allocate(bytes,throwOOME)) == 0L)             throw new RuntimeException("String_Node_Str");
            long hash=serializeForPut(key,value,keyLen,valueLen,hashEntryAdr);
            HashEntries.init(hash,keyLen,valueLen,hashEntryAdr,Util.SENTINEL_NOT_PRESENT);
            if (!segment.replaceEntry(hash,sentinelHashEntryAdr,hashEntryAdr,bytes))             throw new RuntimeException("String_Node_Str");
            replaced=true;
            HashEntries.setSentinel(sentinelHashEntryAdr,Util.SENTINEL_SUCCESS);
            HashEntries.dereference(sentinelHashEntryAdr);
          }
 catch (          PermanentLoadException e) {
            HashEntries.setSentinel(sentinelHashEntryAdr,Util.SENTINEL_PERMANENT_FAILURE);
            throw e;
          }
catch (          Throwable e) {
            failure=e instanceof Exception ? (Exception)e : new RuntimeException(e);
            HashEntries.setSentinel(sentinelHashEntryAdr,Util.SENTINEL_TEMPORARY_FAILURE);
            if (replaced)             HashEntries.dereference(sentinelHashEntryAdr);
 else             segment.removeEntry(sentinelHashEntryAdr);
          }
          if (failure != null)           throw failure;
          return value;
        }
      }
);
    }
 else {
      Uns.free(hashEntryAdr);
    }
  }
  int sentinelStatus=HashEntries.getSentinel(hashEntryAdr);
switch (sentinelStatus) {
case Util.SENTINEL_NOT_PRESENT:
    try {
      return Futures.immediateFuture(valueSerializer.deserialize(new HashEntryValueInput(hashEntryAdr)));
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
 finally {
      HashEntries.dereference(hashEntryAdr);
    }
case Util.SENTINEL_PERMANENT_FAILURE:
  HashEntries.dereference(hashEntryAdr);
return Futures.immediateFailedFuture(new PermanentLoadException());
}
final SettableFuture<V> future=SettableFuture.create();
final long sentinelHashEntryAdr=hashEntryAdr;
executorService.schedule(new Runnable(){
public void run(){
if (future.isCancelled() || closed) {
  HashEntries.dereference(sentinelHashEntryAdr);
  return;
}
int sentinelStatus=HashEntries.getSentinel(sentinelHashEntryAdr);
switch (sentinelStatus) {
case Util.SENTINEL_SUCCESS:
  break;
case Util.SENTINEL_LOADING:
reschedule(0L);
return;
case Util.SENTINEL_PERMANENT_FAILURE:
failure(0L,new PermanentLoadException());
return;
case Util.SENTINEL_TEMPORARY_FAILURE:
failure(0L,new TemporaryLoadException());
return;
default :
failure(0L,new AssertionError("String_Node_Str" + sentinelStatus));
return;
}
long hashEntryAdr=segment.getEntry(keySource,true);
if (hashEntryAdr == 0L) {
future.setException(new TemporaryLoadException());
}
if (hashEntryAdr == sentinelHashEntryAdr) {
reschedule(0L);
return;
}
sentinelStatus=HashEntries.getSentinel(hashEntryAdr);
switch (sentinelStatus) {
case Util.SENTINEL_NOT_PRESENT:
try {
future.set(valueSerializer.deserialize(new HashEntryValueInput(hashEntryAdr)));
HashEntries.dereference(hashEntryAdr);
HashEntries.dereference(sentinelHashEntryAdr);
}
 catch (Throwable e) {
failure(hashEntryAdr,e);
}
break;
case Util.SENTINEL_SUCCESS:
case Util.SENTINEL_LOADING:
HashEntries.dereference(hashEntryAdr);
reschedule(hashEntryAdr);
break;
case Util.SENTINEL_PERMANENT_FAILURE:
failure(hashEntryAdr,new PermanentLoadException());
break;
case Util.SENTINEL_TEMPORARY_FAILURE:
failure(hashEntryAdr,new TemporaryLoadException());
break;
default :
failure(hashEntryAdr,new AssertionError("String_Node_Str" + sentinelStatus));
break;
}
}
private void failure(long hashEntryAdr,Throwable e){
if (hashEntryAdr != 0L) HashEntries.dereference(hashEntryAdr);
HashEntries.dereference(sentinelHashEntryAdr);
future.setException(e);
}
private void reschedule(long hashEntryAdr){
try {
executorService.schedule(this,10,TimeUnit.MILLISECONDS);
}
 catch (Throwable t) {
failure(hashEntryAdr,t);
}
}
}
,10,TimeUnit.MILLISECONDS);
return future;
}

Fixed version (ground truth):
public Future<V> getWithLoaderAsync(final K key,final CacheLoader<K,V> loader){
  if (key == null)   throw new NullPointerException();
  if (executorService == null || executorService.isShutdown() || closed)   throw new IllegalStateException("String_Node_Str");
  final KeyBuffer keySource=keySource(key);
  final OffHeapMap segment=segment(keySource.hash());
  long hashEntryAdr=segment.getEntry(keySource,true);
  if (hashEntryAdr == 0L) {
    final long keyLen=keySerializer.serializedSize(key);
    long bytes=Util.allocLen(keyLen,0L);
    if ((maxEntrySize > 0L && bytes > maxEntrySize) || (hashEntryAdr=Uns.allocate(bytes,throwOOME)) == 0L) {
      putFailCount++;
      remove(key);
      return Futures.immediateFailedFuture(new RuntimeException("String_Node_Str"));
    }
    final HashEntryKeyOutput keyOut=new HashEntryKeyOutput(hashEntryAdr,keyLen);
    try {
      keySerializer.serialize(key,keyOut);
    }
 catch (    Throwable e) {
      freeAndThrow(e,hashEntryAdr);
    }
    final long hash=keyOut.hash(hasher);
    HashEntries.init(hash,keyLen,0L,hashEntryAdr,Util.SENTINEL_LOADING);
    if (segment.putEntry(hashEntryAdr,hash,keyLen,bytes,true,0L,0L,0L)) {
      final long sentinelHashEntryAdr=hashEntryAdr;
      return executorService.submit(new Callable<V>(){
        public V call() throws Exception {
          Exception failure=null;
          V value=null;
          boolean replaced=false;
          try {
            value=loader.load(key);
            long valueLen=valueSerializer.serializedSize(value);
            long bytes=Util.allocLen(keyLen,valueLen);
            long hashEntryAdr;
            if ((maxEntrySize > 0L && bytes > maxEntrySize) || (hashEntryAdr=Uns.allocate(bytes,throwOOME)) == 0L)             throw new RuntimeException("String_Node_Str");
            long hash=serializeForPut(key,value,keyLen,valueLen,hashEntryAdr);
            HashEntries.init(hash,keyLen,valueLen,hashEntryAdr,Util.SENTINEL_NOT_PRESENT);
            if (!segment.replaceEntry(hash,sentinelHashEntryAdr,hashEntryAdr,bytes))             throw new RuntimeException("String_Node_Str");
            replaced=true;
            HashEntries.setSentinel(sentinelHashEntryAdr,Util.SENTINEL_SUCCESS);
            HashEntries.dereference(sentinelHashEntryAdr);
          }
 catch (          PermanentLoadException e) {
            HashEntries.setSentinel(sentinelHashEntryAdr,Util.SENTINEL_PERMANENT_FAILURE);
            throw e;
          }
catch (          Throwable e) {
            failure=e instanceof Exception ? (Exception)e : new RuntimeException(e);
            HashEntries.setSentinel(sentinelHashEntryAdr,Util.SENTINEL_TEMPORARY_FAILURE);
            if (replaced)             HashEntries.dereference(sentinelHashEntryAdr);
 else             segment.removeEntry(sentinelHashEntryAdr);
          }
          if (failure != null)           throw failure;
          return value;
        }
      }
);
    }
 else {
      Uns.free(hashEntryAdr);
    }
  }
  int sentinelStatus=HashEntries.getSentinel(hashEntryAdr);
switch (sentinelStatus) {
case Util.SENTINEL_NOT_PRESENT:
    try {
      return Futures.immediateFuture(valueSerializer.deserialize(new HashEntryValueInput(hashEntryAdr)));
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
 finally {
      HashEntries.dereference(hashEntryAdr);
    }
case Util.SENTINEL_PERMANENT_FAILURE:
  HashEntries.dereference(hashEntryAdr);
return Futures.immediateFailedFuture(new PermanentLoadException());
}
final SettableFuture<V> future=SettableFuture.create();
final long sentinelHashEntryAdr=hashEntryAdr;
executorService.schedule(new Runnable(){
public void run(){
if (future.isCancelled() || closed) {
  HashEntries.dereference(sentinelHashEntryAdr);
  return;
}
int sentinelStatus=HashEntries.getSentinel(sentinelHashEntryAdr);
switch (sentinelStatus) {
case Util.SENTINEL_SUCCESS:
  break;
case Util.SENTINEL_LOADING:
reschedule(0L);
return;
case Util.SENTINEL_PERMANENT_FAILURE:
failure(0L,new PermanentLoadException());
return;
case Util.SENTINEL_TEMPORARY_FAILURE:
failure(0L,new TemporaryLoadException());
return;
default :
failure(0L,new AssertionError("String_Node_Str" + sentinelStatus));
return;
}
long hashEntryAdr=segment.getEntry(keySource,true);
if (hashEntryAdr == 0L) {
future.setException(new TemporaryLoadException());
}
if (hashEntryAdr == sentinelHashEntryAdr) {
reschedule(0L);
return;
}
sentinelStatus=HashEntries.getSentinel(hashEntryAdr);
switch (sentinelStatus) {
case Util.SENTINEL_NOT_PRESENT:
try {
future.set(valueSerializer.deserialize(new HashEntryValueInput(hashEntryAdr)));
HashEntries.dereference(hashEntryAdr);
HashEntries.dereference(sentinelHashEntryAdr);
}
 catch (Throwable e) {
failure(hashEntryAdr,e);
}
break;
case Util.SENTINEL_SUCCESS:
case Util.SENTINEL_LOADING:
HashEntries.dereference(hashEntryAdr);
reschedule(hashEntryAdr);
break;
case Util.SENTINEL_PERMANENT_FAILURE:
failure(hashEntryAdr,new PermanentLoadException());
break;
case Util.SENTINEL_TEMPORARY_FAILURE:
failure(hashEntryAdr,new TemporaryLoadException());
break;
default :
failure(hashEntryAdr,new AssertionError("String_Node_Str" + sentinelStatus));
break;
}
}
private void failure(long hashEntryAdr,Throwable e){
if (hashEntryAdr != 0L) HashEntries.dereference(hashEntryAdr);
HashEntries.dereference(sentinelHashEntryAdr);
future.setException(e);
}
private void reschedule(long hashEntryAdr){
try {
executorService.schedule(this,10,TimeUnit.MILLISECONDS);
}
 catch (Throwable t) {
failure(hashEntryAdr,t);
}
}
}
,10,TimeUnit.MILLISECONDS);
return future;
}