Program: 91702
Project: 91702
Buggy source:
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
  changes=new ArrayList<Change>();
  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()) {
    exclusionPoint.getOriginalModel().getDependencies();
    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));
    for (    Entry<Dependency,Set<ArtifactKey>> entry : visitor.getSourceMap().entrySet()) {
      locatedKeys.addAll(entry.getValue());
      if (contains(entry.getValue(),entry.getKey())) {
        changes.add(PomHelper.createChange(getFile(project),new RemoveDependencyOperation(entry.getKey()),"String_Node_Str"));
      }
 else {
        CompositeChange change=new CompositeChange("String_Node_Str");
        change.add(PomHelper.createChange(getFile(project),new RemoveDependencyOperation(entry.getKey()),"String_Node_Str"));
        exclusionOp.add(new AddDependencyOperation(entry.getKey()));
        for (        ArtifactKey key : entry.getValue()) {
          exclusionOp.add(new AddExclusionOperation(entry.getKey(),key));
        }
      }
    }
    if (!visitor.getStatus().isOK()) {
      statuses.add(visitor.getStatus());
    }
  }
  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());
      if (contains(entry.getValue(),entry.getKey())) {
        if (project.getFile() != null) {
          changes.add(PomHelper.createChange(getFile(project),new RemoveDependencyOperation(entry.getKey()),"String_Node_Str"));
        }
      }
 else {
        exclusionOp.add(new AddDependencyOperation(entry.getKey()));
        for (        ArtifactKey key : entry.getValue()) {
          exclusionOp.add(new AddExclusionOperation(entry.getKey(),key));
        }
      }
    }
    if (!visitor.getStatus().isOK()) {
      statuses.add(visitor.getStatus());
    }
  }
  changes.add(PomHelper.createChange(getFile(exclusionPoint),new CompoundOperation(exclusionOp.toArray(new Operation[exclusionOp.size()])),getName()));
  if (statuses.size() == 1) {
    return RefactoringStatus.create(statuses.get(0));
  }
 else   if (statuses.size() > 1) {
    return RefactoringStatus.create(new MultiStatus("String_Node_Str",0,statuses.toArray(new IStatus[statuses.size()]),"String_Node_Str",null));
  }
 else   if (locatedKeys.isEmpty()) {
    return RefactoringStatus.createFatalErrorStatus(Messages.AbstractPomHeirarchyRefactoring_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());
    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));
    for (    Entry<Dependency,Set<ArtifactKey>> entry : visitor.getSourceMap().entrySet()) {
      locatedKeys.addAll(entry.getValue());
      if (contains(entry.getValue(),entry.getKey())) {
        changes.add(PomHelper.createChange(getFile(project),new RemoveDependencyOperation(entry.getKey()),"String_Node_Str"));
      }
 else {
        CompositeChange change=new CompositeChange("String_Node_Str");
        change.add(PomHelper.createChange(getFile(project),new RemoveDependencyOperation(entry.getKey()),"String_Node_Str"));
        exclusionOp.add(new AddDependencyOperation(entry.getKey()));
        for (        ArtifactKey key : entry.getValue()) {
          exclusionOp.add(new AddExclusionOperation(entry.getKey(),key));
        }
      }
    }
  }
  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("String_Node_Str",toString(dependency),getMavenProjectFacade(project).getPom().getFullPath())));
          changes.add(PomHelper.createChange(getFile(project),new RemoveDependencyOperation(dependency),"String_Node_Str"));
        }
      }
 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()));
  }
  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()]),"String_Node_Str",null));
  }
 else   if (locatedKeys.isEmpty()) {
    return RefactoringStatus.createFatalErrorStatus(Messages.AbstractPomHeirarchyRefactoring_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();
}