Program: 91696
Project: 91696
Buggy source:
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
  changes=new ArrayList<Change>();
  Set<ArtifactKey> locatedKeys=new HashSet<ArtifactKey>();
  List<IStatus> statuses=new ArrayList<IStatus>();
  SubMonitor monitor=SubMonitor.convert(pm,getHierarchy().size());
  List<Operation> exclusionOp=new ArrayList<Operation>();
  Visitor visitor=locate(exclusionPoint,monitor.newChild(1));
  for (  Entry<Dependency,Set<ArtifactKey>> entry : visitor.getSourceMap().entrySet()) {
    locatedKeys.addAll(entry.getValue());
    if (contains(entry.getValue(),entry.getKey())) {
      exclusionOp.add(new RemoveDependencyOperation(entry.getKey()));
    }
 else {
      for (      ArtifactKey key : entry.getValue()) {
        exclusionOp.add(new AddExclusionOperation(entry.getKey(),key));
      }
    }
  }
  for (  MavenProject project : getDescendants()) {
    visitor=locate(project,monitor.newChild(1));
    List<Operation> operations=new ArrayList<Operation>();
    for (    Entry<Dependency,Set<ArtifactKey>> entry : visitor.getSourceMap().entrySet()) {
      locatedKeys.addAll(entry.getValue());
      Dependency dependency=entry.getKey();
      operations.add(new RemoveDependencyOperation(dependency));
      if (!contains(entry.getValue(),dependency)) {
        exclusionOp.add(new AddDependencyOperation(dependency));
        for (        ArtifactKey key : entry.getValue()) {
          exclusionOp.add(new AddExclusionOperation(dependency,key));
        }
      }
    }
    if (operations.size() > 0) {
      IFile pom=getFile(project);
      changes.add(PomHelper.createChange(pom,new CompoundOperation(operations.toArray(new Operation[operations.size()])),getName(pom)));
    }
  }
  for (  MavenProject project : getAncestors()) {
    visitor=locate(project,monitor.newChild(1));
    for (    Entry<Dependency,Set<ArtifactKey>> entry : locate(project,monitor.newChild(1)).getSourceMap().entrySet()) {
      locatedKeys.addAll(entry.getValue());
      Dependency dependency=entry.getKey();
      if (contains(entry.getValue(),dependency)) {
        if (project.getFile() != null) {
          statuses.add(new Status(IStatus.INFO,PLUGIN_ID,NLS.bind(Messages.ExcludeArtifactRefactoring_removeDependencyFrom,toString(dependency),getMavenProjectFacade(project).getPom().getFullPath())));
          IFile pom=getFile(project);
          changes.add(PomHelper.createChange(getFile(project),new RemoveDependencyOperation(dependency),getName(pom)));
        }
      }
 else {
        exclusionOp.add(new AddDependencyOperation(dependency));
        for (        ArtifactKey key : entry.getValue()) {
          exclusionOp.add(new AddExclusionOperation(dependency,key));
        }
      }
    }
  }
  if (!exclusionOp.isEmpty()) {
    changes.add(PomHelper.createChange(getFile(exclusionPoint),new CompoundOperation(exclusionOp.toArray(new Operation[exclusionOp.size()])),getName(pomFile)));
  }
  if (statuses.size() == 1) {
    return RefactoringStatus.create(statuses.get(0));
  }
 else   if (statuses.size() > 1) {
    return RefactoringStatus.create(new MultiStatus(PLUGIN_ID,0,statuses.toArray(new IStatus[statuses.size()]),Messages.ExcludeArtifactRefactoring_errorCreatingRefactoring,null));
  }
 else   if (locatedKeys.isEmpty()) {
    return RefactoringStatus.createFatalErrorStatus(Messages.ExcludeArtifactRefactoring_noTargets);
  }
 else   if (locatedKeys.size() != keys.length) {
    StringBuilder sb=new StringBuilder();
    for (    ArtifactKey key : keys) {
      if (!locatedKeys.contains(key)) {
        sb.append(key.toString()).append(',');
      }
    }
    sb.deleteCharAt(sb.length() - 1);
    return RefactoringStatus.createErrorStatus(NLS.bind(Messages.ExcludeArtifactRefactoring_failedToLocateArtifact,sb.toString()));
  }
  return new RefactoringStatus();
}

Fixed version (ground truth):
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
  changes=new ArrayList<Change>();
  Set<ArtifactKey> locatedKeys=new HashSet<ArtifactKey>();
  List<IStatus> statuses=new ArrayList<IStatus>();
  SubMonitor monitor=SubMonitor.convert(pm,getHierarchy().size());
  List<Operation> exclusionOp=new ArrayList<Operation>();
  Visitor visitor=locate(exclusionPoint,monitor.newChild(1));
  for (  Entry<Dependency,Set<ArtifactKey>> entry : visitor.getSourceMap().entrySet()) {
    locatedKeys.addAll(entry.getValue());
    Dependency dependency=entry.getKey();
    if (contains(entry.getValue(),dependency)) {
      exclusionOp.add(new RemoveDependencyOperation(dependency));
    }
 else {
      for (      ArtifactKey key : entry.getValue()) {
        if (!hasExclusion(exclusionPoint,dependency,key)) {
          exclusionOp.add(new AddExclusionOperation(dependency,key));
        }
      }
    }
  }
  for (  MavenProject project : getDescendants()) {
    visitor=locate(project,monitor.newChild(1));
    List<Operation> operations=new ArrayList<Operation>();
    for (    Entry<Dependency,Set<ArtifactKey>> entry : visitor.getSourceMap().entrySet()) {
      locatedKeys.addAll(entry.getValue());
      Dependency dependency=entry.getKey();
      operations.add(new RemoveDependencyOperation(dependency));
      if (!contains(entry.getValue(),dependency)) {
        if (!hasDependency(exclusionPoint,dependency)) {
          exclusionOp.add(new AddDependencyOperation(dependency));
        }
        for (        ArtifactKey key : entry.getValue()) {
          if (!hasExclusion(exclusionPoint,dependency,key)) {
            exclusionOp.add(new AddExclusionOperation(dependency,key));
          }
        }
      }
    }
    if (operations.size() > 0) {
      IFile pom=getFile(project);
      changes.add(PomHelper.createChange(pom,new CompoundOperation(operations.toArray(new Operation[operations.size()])),getName(pom)));
    }
  }
  for (  MavenProject project : getAncestors()) {
    visitor=locate(project,monitor.newChild(1));
    for (    Entry<Dependency,Set<ArtifactKey>> entry : locate(project,monitor.newChild(1)).getSourceMap().entrySet()) {
      locatedKeys.addAll(entry.getValue());
      Dependency dependency=entry.getKey();
      if (contains(entry.getValue(),dependency)) {
        if (project.getFile() != null) {
          statuses.add(new Status(IStatus.INFO,PLUGIN_ID,NLS.bind(Messages.ExcludeArtifactRefactoring_removeDependencyFrom,toString(dependency),getMavenProjectFacade(project).getPom().getFullPath())));
          IFile pom=getFile(project);
          changes.add(PomHelper.createChange(getFile(project),new RemoveDependencyOperation(dependency),getName(pom)));
        }
      }
 else {
        exclusionOp.add(new AddDependencyOperation(dependency));
        for (        ArtifactKey key : entry.getValue()) {
          if (!hasExclusion(exclusionPoint,dependency,key)) {
            exclusionOp.add(new AddExclusionOperation(dependency,key));
          }
        }
      }
    }
  }
  if (!exclusionOp.isEmpty()) {
    IFile pom=getFile(exclusionPoint);
    changes.add(PomHelper.createChange(pom,new CompoundOperation(exclusionOp.toArray(new Operation[exclusionOp.size()])),getName(pom)));
  }
  if (statuses.size() == 1) {
    return RefactoringStatus.create(statuses.get(0));
  }
 else   if (statuses.size() > 1) {
    return RefactoringStatus.create(new MultiStatus(PLUGIN_ID,0,statuses.toArray(new IStatus[statuses.size()]),Messages.ExcludeArtifactRefactoring_errorCreatingRefactoring,null));
  }
 else   if (locatedKeys.isEmpty()) {
    return RefactoringStatus.createFatalErrorStatus(Messages.ExcludeArtifactRefactoring_noTargets);
  }
 else   if (locatedKeys.size() != keys.length) {
    StringBuilder sb=new StringBuilder();
    for (    ArtifactKey key : keys) {
      if (!locatedKeys.contains(key)) {
        sb.append(key.toString()).append(',');
      }
    }
    sb.deleteCharAt(sb.length() - 1);
    return RefactoringStatus.createErrorStatus(NLS.bind(Messages.ExcludeArtifactRefactoring_failedToLocateArtifact,sb.toString()));
  }
  return new RefactoringStatus();
}