Program: 6551
Project: 6551
Buggy source:
/** 
 * Scan all files in the local system artifact directory, looking for jar files and adding them as system artifacts. If the artifact already exists it will not be added again unless it is a snapshot version.
 * @throws IOException if there was some IO error adding the system artifacts
 * @throws WriteConflictException if there was a write conflicting adding the system artifact. This shouldn't happen,but if it does, it should be ok to retry the operation.
 */
public void addSystemArtifacts() throws IOException, WriteConflictException {
  List<ArtifactConfig> systemArtifacts=new ArrayList<>();
  for (  File jarFile : DirUtils.listFiles(systemArtifactDir,"String_Node_Str")) {
    Id.Artifact artifactId;
    try {
      artifactId=Id.Artifact.parse(Id.Namespace.SYSTEM,jarFile.getName());
    }
 catch (    IllegalArgumentException e) {
      LOG.warn(String.format("String_Node_Str",e.getMessage()));
      continue;
    }
    String artifactFileName=jarFile.getName();
    String configFileName=artifactFileName.substring(0,artifactFileName.length() - "String_Node_Str".length()) + "String_Node_Str";
    File configFile=new File(systemArtifactDir,configFileName);
    try {
      ArtifactConfig artifactConfig=configFile.isFile() ? ArtifactConfig.read(artifactId,configFile,jarFile) : ArtifactConfig.builder(artifactId,jarFile).build();
      validateParentSet(artifactId,artifactConfig.getParents());
      validatePluginSet(artifactConfig.getPlugins());
      systemArtifacts.add(artifactConfig);
    }
 catch (    InvalidArtifactException e) {
      LOG.warn(String.format("String_Node_Str",artifactFileName),e);
    }
  }
  Collections.sort(systemArtifacts);
  for (  ArtifactConfig artifactConfig : systemArtifacts) {
    String fileName=artifactConfig.getFile().getName();
    try {
      Id.Artifact artifactId=artifactConfig.getArtifactId();
      if (!artifactId.getVersion().isSnapshot()) {
        try {
          artifactStore.getArtifact(artifactId);
          continue;
        }
 catch (        ArtifactNotFoundException e) {
        }
      }
      addArtifact(artifactId,artifactConfig.getFile(),artifactConfig.getParents(),artifactConfig.getPlugins());
    }
 catch (    ArtifactAlreadyExistsException e) {
    }
catch (    ArtifactRangeNotFoundException e) {
      LOG.warn(String.format("String_Node_Str",fileName),e);
    }
catch (    InvalidArtifactException e) {
      LOG.warn(String.format("String_Node_Str",fileName),e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Scan all files in the local system artifact directory, looking for jar files and adding them as system artifacts. If the artifact already exists it will not be added again unless it is a snapshot version.
 * @throws IOException if there was some IO error adding the system artifacts
 * @throws WriteConflictException if there was a write conflicting adding the system artifact. This shouldn't happen,but if it does, it should be ok to retry the operation.
 */
public void addSystemArtifacts() throws IOException, WriteConflictException {
  List<ArtifactConfig> systemArtifacts=new ArrayList<>();
  for (  File jarFile : DirUtils.listFiles(systemArtifactDir,"String_Node_Str")) {
    Id.Artifact artifactId;
    try {
      artifactId=Id.Artifact.parse(Id.Namespace.SYSTEM,jarFile.getName());
    }
 catch (    IllegalArgumentException e) {
      LOG.warn(String.format("String_Node_Str",e.getMessage()));
      continue;
    }
    String artifactFileName=jarFile.getName();
    String configFileName=artifactFileName.substring(0,artifactFileName.length() - "String_Node_Str".length()) + "String_Node_Str";
    File configFile=new File(systemArtifactDir,configFileName);
    try {
      ArtifactConfig artifactConfig=configFile.isFile() ? ArtifactConfig.read(artifactId,configFile,jarFile) : ArtifactConfig.builder(artifactId,jarFile).build();
      validateParentSet(artifactId,artifactConfig.getParents());
      validatePluginSet(artifactConfig.getPlugins());
      systemArtifacts.add(artifactConfig);
    }
 catch (    InvalidArtifactException e) {
      LOG.warn(String.format("String_Node_Str",artifactFileName),e);
    }
  }
  Collections.sort(systemArtifacts);
  Set<Id.Artifact> parents=new HashSet<>();
  for (  ArtifactConfig child : systemArtifacts) {
    Id.Artifact childId=child.getArtifactId();
    for (    ArtifactConfig potentialParent : systemArtifacts) {
      Id.Artifact potentialParentId=potentialParent.getArtifactId();
      if (childId.equals(potentialParentId)) {
        continue;
      }
      if (child.hasParent(potentialParentId)) {
        parents.add(potentialParentId);
      }
    }
  }
  for (  ArtifactConfig config : systemArtifacts) {
    if (parents.contains(config.getArtifactId())) {
      addSystemArtifact(config);
    }
  }
  for (  ArtifactConfig config : systemArtifacts) {
    if (!parents.contains(config.getArtifactId())) {
      addSystemArtifact(config);
    }
  }
}