Program: 110526
Project: 110526
Buggy source:
/** 
 * Retrieves and deserializes the NestedSet contents associated with the given fingerprint. 
 */
public ListenableFuture<Object[]> getContentsAndDeserialize(ByteString fingerprint,DeserializationContext deserializationContext) throws IOException {
  ListenableFuture<Object[]> contents=nestedSetCache.contentsForFingerprint(fingerprint);
  if (contents != null) {
    return contents;
  }
  ListenableFuture<byte[]> retrieved=nestedSetStorageEndpoint.get(fingerprint);
  ListenableFuture<Object[]> result=Futures.transformAsync(retrieved,bytes -> {
    CodedInputStream codedIn=CodedInputStream.newInstance(bytes);
    int numberOfElements=codedIn.readInt32();
    DeserializationContext newDeserializationContext=deserializationContext.getNewMemoizingContext();
    List<ListenableFuture<?>> deserializationFutures=new ArrayList<>();
    for (int i=0; i < numberOfElements; i++) {
      Object deserializedElement=newDeserializationContext.deserialize(codedIn);
      if (deserializedElement instanceof ByteString) {
        deserializationFutures.add(getContentsAndDeserialize((ByteString)deserializedElement,deserializationContext));
      }
 else {
        deserializationFutures.add(Futures.immediateFuture(deserializedElement));
      }
    }
    return Futures.whenAllComplete(deserializationFutures).call(() -> {
      Object[] deserializedContents=new Object[deserializationFutures.size()];
      for (int i=0; i < deserializationFutures.size(); i++) {
        deserializedContents[i]=Futures.getDone(deserializationFutures.get(i));
      }
      return deserializedContents;
    }
,executor);
  }
,executor);
  FingerprintComputationResult fingerprintComputationResult=FingerprintComputationResult.create(fingerprint,Futures.immediateFuture(null));
  nestedSetCache.put(fingerprintComputationResult,result);
  return result;
}

Fixed version (ground truth):
/** 
 * Retrieves and deserializes the NestedSet contents associated with the given fingerprint. <p>We wish to only do one deserialization per fingerprint. This is enforced by the   {@link #nestedSetCache}, which is responsible for returning the canonical future that will contain the results of the deserialization. If that future is not owned by the current call of this method, it doesn't have to do anything further.
 */
ListenableFuture<Object[]> getContentsAndDeserialize(ByteString fingerprint,DeserializationContext deserializationContext) throws IOException {
  SettableFuture<Object[]> future=SettableFuture.create();
  ListenableFuture<Object[]> contents=nestedSetCache.putIfAbsent(fingerprint,future);
  if (contents != null) {
    return contents;
  }
  ListenableFuture<byte[]> retrieved=nestedSetStorageEndpoint.get(fingerprint);
  future.setFuture(Futures.transformAsync(retrieved,bytes -> {
    CodedInputStream codedIn=CodedInputStream.newInstance(bytes);
    int numberOfElements=codedIn.readInt32();
    DeserializationContext newDeserializationContext=deserializationContext.getNewMemoizingContext();
    List<ListenableFuture<?>> deserializationFutures=new ArrayList<>();
    for (int i=0; i < numberOfElements; i++) {
      Object deserializedElement=newDeserializationContext.deserialize(codedIn);
      if (deserializedElement instanceof ByteString) {
        deserializationFutures.add(getContentsAndDeserialize((ByteString)deserializedElement,deserializationContext));
      }
 else {
        deserializationFutures.add(Futures.immediateFuture(deserializedElement));
      }
    }
    return Futures.whenAllComplete(deserializationFutures).call(() -> {
      Object[] deserializedContents=new Object[deserializationFutures.size()];
      for (int i=0; i < deserializationFutures.size(); i++) {
        deserializedContents[i]=Futures.getDone(deserializationFutures.get(i));
      }
      return deserializedContents;
    }
,executor);
  }
,executor));
  return future;
}