Program: 6858
Project: 6858
Buggy source:
@Category(SlowTests.class) @Test public void testConcurrentSnapshotWrite() throws Exception {
  int numThreads=20;
  final Id.Artifact artifactId=Id.Artifact.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str","String_Node_Str");
  final List<String> successfulWriters=Collections.synchronizedList(Lists.<String>newArrayList());
  final CyclicBarrier barrier=new CyclicBarrier(numThreads);
  final CountDownLatch latch=new CountDownLatch(numThreads);
  ExecutorService executorService=Executors.newFixedThreadPool(numThreads);
  for (int i=0; i < numThreads; i++) {
    final String writer=String.valueOf(i);
    executorService.execute(new Runnable(){
      @Override public void run(){
        try {
          barrier.await();
          ArtifactMeta meta=new ArtifactMeta(ImmutableList.of(new PluginClass("String_Node_Str","String_Node_Str" + writer,"String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.<String,PluginPropertyField>of())));
          artifactStore.write(artifactId,meta,new ByteArrayInputStream(Bytes.toBytes(writer)));
          successfulWriters.add(writer);
        }
 catch (        InterruptedException|BrokenBarrierException|ArtifactAlreadyExistsException|IOException e) {
          throw new RuntimeException(e);
        }
catch (        WriteConflictException e) {
        }
 finally {
          latch.countDown();
        }
      }
    }
);
  }
  latch.await();
  String winnerWriter=successfulWriters.get(successfulWriters.size() - 1);
  ArtifactDetail detail=artifactStore.getArtifact(artifactId);
  ArtifactMeta expectedMeta=new ArtifactMeta(ImmutableList.of(new PluginClass("String_Node_Str","String_Node_Str" + winnerWriter,"String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.<String,PluginPropertyField>of())));
  assertEqual(artifactId,expectedMeta,winnerWriter,detail);
  Map<ArtifactInfo,List<PluginClass>> pluginMap=artifactStore.getPluginClasses(artifactId.getNamespace(),"String_Node_Str");
  Map<ArtifactInfo,List<PluginClass>> expected=Maps.newHashMap();
  expected.put(detail.getInfo(),Lists.newArrayList(new PluginClass("String_Node_Str","String_Node_Str" + winnerWriter,"String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.<String,PluginPropertyField>of())));
  Assert.assertEquals(expected,pluginMap);
}

Fixed version (ground truth):
@Category(SlowTests.class) @Test public void testConcurrentSnapshotWrite() throws Exception {
  int numThreads=20;
  final Id.Artifact artifactId=Id.Artifact.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str","String_Node_Str");
  final CyclicBarrier barrier=new CyclicBarrier(numThreads);
  final CountDownLatch latch=new CountDownLatch(numThreads);
  ExecutorService executorService=Executors.newFixedThreadPool(numThreads);
  for (int i=0; i < numThreads; i++) {
    final String writer=String.valueOf(i);
    executorService.execute(new Runnable(){
      @Override public void run(){
        try {
          barrier.await();
          ArtifactMeta meta=new ArtifactMeta(ImmutableList.of(new PluginClass("String_Node_Str","String_Node_Str" + writer,"String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.<String,PluginPropertyField>of())));
          artifactStore.write(artifactId,meta,new ByteArrayInputStream(Bytes.toBytes(writer)));
        }
 catch (        InterruptedException|BrokenBarrierException|ArtifactAlreadyExistsException|IOException e) {
          throw new RuntimeException(e);
        }
catch (        WriteConflictException e) {
        }
 finally {
          latch.countDown();
        }
      }
    }
);
  }
  latch.await();
  ArtifactDetail detail=artifactStore.getArtifact(artifactId);
  String pluginName=detail.getMeta().getPlugins().get(0).getName();
  String winnerWriter=pluginName.substring("String_Node_Str".length());
  ArtifactMeta expectedMeta=new ArtifactMeta(ImmutableList.of(new PluginClass("String_Node_Str","String_Node_Str" + winnerWriter,"String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.<String,PluginPropertyField>of())));
  assertEqual(artifactId,expectedMeta,winnerWriter,detail);
  Map<ArtifactInfo,List<PluginClass>> pluginMap=artifactStore.getPluginClasses(artifactId.getNamespace(),"String_Node_Str");
  Map<ArtifactInfo,List<PluginClass>> expected=Maps.newHashMap();
  expected.put(detail.getInfo(),Lists.newArrayList(new PluginClass("String_Node_Str","String_Node_Str" + winnerWriter,"String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.<String,PluginPropertyField>of())));
  Assert.assertEquals(expected,pluginMap);
}