Program: 6874
Project: 6874
Buggy source:
/** 
 * Write the artifact and its metadata to the store. Once added, artifacts cannot be changed. TODO: add support for snapshot versions, which can be changed
 * @param artifactId the id of the artifact to add
 * @param artifactMeta the metadata for the artifact
 * @param archiveContents the contents of the artifact
 * @throws WriteConflictException if the artifact is already currently being written
 * @throws ArtifactAlreadyExistsException if a non-snapshot version of the artifact already exists
 * @throws IOException if there was an exception persisting the artifact contents to the filesystem,of persisting the artifact metadata to the metastore
 */
public void write(Id.Artifact artifactId,ArtifactMeta artifactMeta,InputStream archiveContents) throws WriteConflictException, ArtifactAlreadyExistsException, IOException {
  ArtifactMeta meta=readMeta(artifactId);
  if (meta != null) {
    throw new ArtifactAlreadyExistsException(artifactId);
  }
  Location fileDirectory=locationFactory.get(artifactId.getNamespace(),ARTIFACTS_PATH).append(artifactId.getName());
  Locations.mkdirsIfNotExists(fileDirectory);
  Location lock=fileDirectory.append(artifactId.getVersion() + "String_Node_Str");
  if (!lock.createNew()) {
    throw new WriteConflictException(artifactId);
  }
  Location file=fileDirectory.append(artifactId.getVersion());
  if (file.exists()) {
    file.delete();
  }
  try {
    ByteStreams.copy(archiveContents,file.getOutputStream());
    try {
      writeMeta(artifactId,artifactMeta);
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str" + artifactId,e);
      file.delete();
      throw new IOException(e);
    }
  }
  finally {
    lock.delete();
  }
}

Fixed version (ground truth):
/** 
 * Write the artifact and its metadata to the store. Once added, artifacts cannot be changed. TODO: add support for snapshot versions, which can be changed
 * @param artifactId the id of the artifact to add
 * @param artifactMeta the metadata for the artifact
 * @param archiveContents the contents of the artifact
 * @throws WriteConflictException if the artifact is already currently being written
 * @throws ArtifactAlreadyExistsException if a non-snapshot version of the artifact already exists
 * @throws IOException if there was an exception persisting the artifact contents to the filesystem,of persisting the artifact metadata to the metastore
 */
public void write(Id.Artifact artifactId,ArtifactMeta artifactMeta,InputStream archiveContents) throws WriteConflictException, ArtifactAlreadyExistsException, IOException {
  Location fileDirectory=locationFactory.get(artifactId.getNamespace(),ARTIFACTS_PATH).append(artifactId.getName());
  Locations.mkdirsIfNotExists(fileDirectory);
  Location lock=fileDirectory.append(artifactId.getVersion() + "String_Node_Str");
  if (!lock.createNew()) {
    throw new WriteConflictException(artifactId);
  }
  ArtifactMeta meta=readMeta(artifactId);
  if (meta != null) {
    lock.delete();
    throw new ArtifactAlreadyExistsException(artifactId);
  }
  Location file=fileDirectory.append(artifactId.getVersion());
  if (file.exists()) {
    file.delete();
  }
  try {
    ByteStreams.copy(archiveContents,file.getOutputStream());
    try {
      writeMeta(artifactId,artifactMeta);
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str" + artifactId,e);
      file.delete();
      throw new IOException(e);
    }
  }
  finally {
    lock.delete();
  }
}