Program: 6484
Project: 6484
Buggy source:
/** 
 * Returns a   {@link Map.Entry} representing the plugin information for the plugin being requested.
 * @param artifactId the id of the artifact to get plugins for
 * @param pluginType plugin type name
 * @param pluginName plugin name
 * @param selector for selecting which plugin to use
 * @return the entry found
 * @throws IOException if there was an exception reading plugin metadata from the artifact store
 * @throws PluginNotExistsException if no plugins of the given type and name are available to the given artifact
 */
public Map.Entry<ArtifactDescriptor,PluginClass> findPlugin(Id.Artifact artifactId,String pluginType,String pluginName,PluginSelector selector) throws IOException, PluginNotExistsException {
  SortedMap<ArtifactDescriptor,PluginClass> pluginClasses=artifactStore.getPluginClasses(artifactId,pluginType,pluginName);
  SortedMap<ArtifactId,PluginClass> artifactIds=Maps.newTreeMap();
  for (  Map.Entry<ArtifactDescriptor,PluginClass> pluginClassEntry : pluginClasses.entrySet()) {
    artifactIds.put(pluginClassEntry.getKey().getArtifactId(),pluginClassEntry.getValue());
  }
  Map.Entry<ArtifactId,PluginClass> chosenArtifact=selector.select(artifactIds);
  if (chosenArtifact == null) {
    throw new PluginNotExistsException(artifactId,pluginType,pluginName);
  }
  for (  Map.Entry<ArtifactDescriptor,PluginClass> pluginClassEntry : pluginClasses.entrySet()) {
    if (pluginClassEntry.getKey().getArtifactId().compareTo(chosenArtifact.getKey()) == 0) {
      return pluginClassEntry;
    }
  }
  throw new PluginNotExistsException(artifactId,pluginType,pluginName);
}

Fixed version (ground truth):
/** 
 * Returns a   {@link Map.Entry} representing the plugin information for the plugin being requested.
 * @param artifactId the id of the artifact to get plugins for
 * @param pluginType plugin type name
 * @param pluginName plugin name
 * @param selector for selecting which plugin to use
 * @return the entry found
 * @throws IOException if there was an exception reading plugin metadata from the artifact store
 * @throws ArtifactNotFoundException if the given artifact does not exist
 * @throws PluginNotExistsException if no plugins of the given type and name are available to the given artifact
 */
public Map.Entry<ArtifactDescriptor,PluginClass> findPlugin(Id.Artifact artifactId,String pluginType,String pluginName,PluginSelector selector) throws IOException, PluginNotExistsException, ArtifactNotFoundException {
  SortedMap<ArtifactDescriptor,PluginClass> pluginClasses=artifactStore.getPluginClasses(artifactId,pluginType,pluginName);
  SortedMap<ArtifactId,PluginClass> artifactIds=Maps.newTreeMap();
  for (  Map.Entry<ArtifactDescriptor,PluginClass> pluginClassEntry : pluginClasses.entrySet()) {
    artifactIds.put(pluginClassEntry.getKey().getArtifactId(),pluginClassEntry.getValue());
  }
  Map.Entry<ArtifactId,PluginClass> chosenArtifact=selector.select(artifactIds);
  if (chosenArtifact == null) {
    throw new PluginNotExistsException(artifactId,pluginType,pluginName);
  }
  for (  Map.Entry<ArtifactDescriptor,PluginClass> pluginClassEntry : pluginClasses.entrySet()) {
    if (pluginClassEntry.getKey().getArtifactId().compareTo(chosenArtifact.getKey()) == 0) {
      return pluginClassEntry;
    }
  }
  throw new PluginNotExistsException(artifactId,pluginType,pluginName);
}