Program: 110527
Project: 110527
Buggy source:
@Test public void testDeserializationInParallel() throws Exception {
  NestedSetStorageEndpoint nestedSetStorageEndpoint=Mockito.spy(new InMemoryNestedSetStorageEndpoint());
  NestedSetCache emptyNestedSetCache=Mockito.mock(NestedSetCache.class);
  NestedSetStore nestedSetStore=new NestedSetStore(nestedSetStorageEndpoint,emptyNestedSetCache,MoreExecutors.directExecutor());
  ObjectCodecs objectCodecs=new ObjectCodecs(AutoRegistry.get().getBuilder().setAllowDefaultCodec(true).add(new NestedSetCodecWithStore<>(nestedSetStore)).build());
  NestedSet<String> subset1=new NestedSetBuilder<String>(Order.STABLE_ORDER).add("String_Node_Str").add("String_Node_Str").build();
  SettableFuture<byte[]> subset1Future=SettableFuture.create();
  NestedSet<String> subset2=new NestedSetBuilder<String>(Order.STABLE_ORDER).add("String_Node_Str").add("String_Node_Str").build();
  SettableFuture<byte[]> subset2Future=SettableFuture.create();
  NestedSet<String> set=new NestedSetBuilder<String>(Order.STABLE_ORDER).addTransitive(subset1).addTransitive(subset2).build();
  ArgumentCaptor<ByteString> fingerprintCaptor=ArgumentCaptor.forClass(ByteString.class);
  ByteString fingerprint=nestedSetStore.computeFingerprintAndStore((Object[])set.getChildren(),objectCodecs.getSerializationContext()).fingerprint();
  Mockito.verify(nestedSetStorageEndpoint,Mockito.times(3)).put(fingerprintCaptor.capture(),Mockito.any());
  Mockito.doReturn(subset1Future).when(nestedSetStorageEndpoint).get(fingerprintCaptor.getAllValues().get(0));
  Mockito.doReturn(subset2Future).when(nestedSetStorageEndpoint).get(fingerprintCaptor.getAllValues().get(1));
  ListenableFuture<Object[]> deserializationFuture=nestedSetStore.getContentsAndDeserialize(fingerprint,objectCodecs.getDeserializationContext());
  assertThat(deserializationFuture.isDone()).isFalse();
  Mockito.verify(nestedSetStorageEndpoint,Mockito.times(3)).get(Mockito.any());
  subset1Future.set(ByteString.copyFrom("String_Node_Str",Charset.defaultCharset()).toByteArray());
  subset2Future.set(ByteString.copyFrom("String_Node_Str",Charset.defaultCharset()).toByteArray());
  assertThat(deserializationFuture.isDone()).isTrue();
}

Fixed version (ground truth):
@Test public void testDeserializationInParallel() throws Exception {
  NestedSetStorageEndpoint nestedSetStorageEndpoint=Mockito.spy(new InMemoryNestedSetStorageEndpoint());
  NestedSetCache emptyNestedSetCache=Mockito.mock(NestedSetCache.class);
  NestedSetStore nestedSetStore=new NestedSetStore(nestedSetStorageEndpoint,emptyNestedSetCache,MoreExecutors.directExecutor());
  ObjectCodecs objectCodecs=new ObjectCodecs(AutoRegistry.get().getBuilder().setAllowDefaultCodec(true).add(new NestedSetCodecWithStore<>(nestedSetStore)).build());
  NestedSet<String> subset1=new NestedSetBuilder<String>(Order.STABLE_ORDER).add("String_Node_Str").add("String_Node_Str").build();
  SettableFuture<byte[]> subset1Future=SettableFuture.create();
  NestedSet<String> subset2=new NestedSetBuilder<String>(Order.STABLE_ORDER).add("String_Node_Str").add("String_Node_Str").build();
  SettableFuture<byte[]> subset2Future=SettableFuture.create();
  NestedSet<String> set=new NestedSetBuilder<String>(Order.STABLE_ORDER).addTransitive(subset1).addTransitive(subset2).build();
  ArgumentCaptor<ByteString> fingerprintCaptor=ArgumentCaptor.forClass(ByteString.class);
  ByteString fingerprint=nestedSetStore.computeFingerprintAndStore((Object[])set.getChildren(),objectCodecs.getSerializationContext()).fingerprint();
  Mockito.verify(nestedSetStorageEndpoint,Mockito.times(3)).put(fingerprintCaptor.capture(),Mockito.any());
  Mockito.doReturn(subset1Future).when(nestedSetStorageEndpoint).get(fingerprintCaptor.getAllValues().get(0));
  Mockito.doReturn(subset2Future).when(nestedSetStorageEndpoint).get(fingerprintCaptor.getAllValues().get(1));
  Mockito.when(emptyNestedSetCache.putIfAbsent(Mockito.any(),Mockito.any())).thenAnswer(invocation -> null);
  ListenableFuture<Object[]> deserializationFuture=nestedSetStore.getContentsAndDeserialize(fingerprint,objectCodecs.getDeserializationContext());
  assertThat(deserializationFuture.isDone()).isFalse();
  Mockito.verify(nestedSetStorageEndpoint,Mockito.times(3)).get(Mockito.any());
  subset1Future.set(ByteString.copyFrom("String_Node_Str",Charset.defaultCharset()).toByteArray());
  subset2Future.set(ByteString.copyFrom("String_Node_Str",Charset.defaultCharset()).toByteArray());
  assertThat(deserializationFuture.isDone()).isTrue();
}