Program: 5533
Project: 5533
Buggy source:
/** 
 * Get all plugin classes of the given type and name that extend the given parent artifact. Results are returned as a map from plugin artifact to plugins in that artifact.
 * @param parentArtifactId the id of the artifact to find plugins for
 * @param type the type of plugin to look for
 * @param name the name of the plugin to look for
 * @return an unmodifiable map of plugin artifact to plugin classes of the given type and name, accessible by thegiven artifact. The map will never be null, and will never be empty.
 * @throws PluginNotExistsException if no plugin with the given type and name exists in the namespace
 * @throws IOException if there was an exception reading metadata from the metastore
 */
public SortedMap<ArtifactDescriptor,PluginClass> getPluginClasses(final NamespaceId namespace,final Id.Artifact parentArtifactId,final String type,final String name) throws IOException, ArtifactNotFoundException, PluginNotExistsException {
  try {
    SortedMap<ArtifactDescriptor,PluginClass> result=Transactions.execute(transactional,new TxCallable<SortedMap<ArtifactDescriptor,PluginClass>>(){
      @Override public SortedMap<ArtifactDescriptor,PluginClass> call(      DatasetContext context) throws Exception {
        Table metaTable=getMetaTable(context);
        ArtifactCell parentCell=new ArtifactCell(parentArtifactId);
        byte[] parentDataBytes=metaTable.get(parentCell.rowkey,parentCell.column);
        if (parentDataBytes == null) {
          throw new ArtifactNotFoundException(parentArtifactId.toEntityId());
        }
        SortedMap<ArtifactDescriptor,PluginClass> plugins=new TreeMap<>();
        ArtifactData parentData=GSON.fromJson(Bytes.toString(parentDataBytes),ArtifactData.class);
        Set<PluginClass> parentPlugins=parentData.meta.getClasses().getPlugins();
        for (        PluginClass pluginClass : parentPlugins) {
          if (pluginClass.getName().equals(name) && pluginClass.getType().equals(type)) {
            ArtifactDescriptor parentDescriptor=new ArtifactDescriptor(parentArtifactId.toArtifactId(),locationFactory.create(parentData.locationURI));
            plugins.put(parentDescriptor,pluginClass);
            break;
          }
        }
        PluginKey pluginKey=new PluginKey(parentArtifactId.getNamespace(),parentArtifactId.getName(),type,name);
        Row row=metaTable.get(pluginKey.getRowKey());
        if (!row.isEmpty()) {
          for (          Map.Entry<byte[],byte[]> column : row.getColumns().entrySet()) {
            ImmutablePair<ArtifactDescriptor,PluginClass> pluginEntry=getPluginEntry(namespace,parentArtifactId,column);
            if (pluginEntry != null) {
              plugins.put(pluginEntry.getFirst(),pluginEntry.getSecond());
            }
          }
        }
        return Collections.unmodifiableSortedMap(plugins);
      }
    }
);
    if (result.isEmpty()) {
      throw new PluginNotExistsException(parentArtifactId.getNamespace(),type,name);
    }
    return result;
  }
 catch (  TransactionFailureException e) {
    throw Transactions.propagate(e,IOException.class,ArtifactNotFoundException.class);
  }
}

Fixed version (ground truth):
/** 
 * Get all plugin classes of the given type and name that extend the given parent artifact. Results are returned as a map from plugin artifact to plugins in that artifact.
 * @param parentArtifactId the id of the artifact to find plugins for
 * @param type the type of plugin to look for
 * @param name the name of the plugin to look for
 * @return an unmodifiable map of plugin artifact to plugin classes of the given type and name, accessible by thegiven artifact. The map will never be null, and will never be empty.
 * @throws PluginNotExistsException if no plugin with the given type and name exists in the namespace
 * @throws IOException if there was an exception reading metadata from the metastore
 */
public SortedMap<ArtifactDescriptor,PluginClass> getPluginClasses(final NamespaceId namespace,final Id.Artifact parentArtifactId,final String type,final String name) throws IOException, ArtifactNotFoundException, PluginNotExistsException {
  try {
    SortedMap<ArtifactDescriptor,PluginClass> result=Transactions.execute(transactional,new TxCallable<SortedMap<ArtifactDescriptor,PluginClass>>(){
      @Override public SortedMap<ArtifactDescriptor,PluginClass> call(      DatasetContext context) throws Exception {
        Table metaTable=getMetaTable(context);
        ArtifactCell parentCell=new ArtifactCell(parentArtifactId);
        byte[] parentDataBytes=metaTable.get(parentCell.rowkey,parentCell.column);
        if (parentDataBytes == null) {
          throw new ArtifactNotFoundException(parentArtifactId.toEntityId());
        }
        SortedMap<ArtifactDescriptor,PluginClass> plugins=new TreeMap<>();
        ArtifactData parentData=GSON.fromJson(Bytes.toString(parentDataBytes),ArtifactData.class);
        Set<PluginClass> parentPlugins=parentData.meta.getClasses().getPlugins();
        for (        PluginClass pluginClass : parentPlugins) {
          if (pluginClass.getName().equals(name) && pluginClass.getType().equals(type)) {
            ArtifactDescriptor parentDescriptor=new ArtifactDescriptor(parentArtifactId.toArtifactId(),Locations.getCompatibleLocation(locationFactory,parentData.locationPath,parentData.locationURI));
            plugins.put(parentDescriptor,pluginClass);
            break;
          }
        }
        PluginKey pluginKey=new PluginKey(parentArtifactId.getNamespace(),parentArtifactId.getName(),type,name);
        Row row=metaTable.get(pluginKey.getRowKey());
        if (!row.isEmpty()) {
          for (          Map.Entry<byte[],byte[]> column : row.getColumns().entrySet()) {
            ImmutablePair<ArtifactDescriptor,PluginClass> pluginEntry=getPluginEntry(namespace,parentArtifactId,column);
            if (pluginEntry != null) {
              plugins.put(pluginEntry.getFirst(),pluginEntry.getSecond());
            }
          }
        }
        return Collections.unmodifiableSortedMap(plugins);
      }
    }
);
    if (result.isEmpty()) {
      throw new PluginNotExistsException(parentArtifactId.getNamespace(),type,name);
    }
    return result;
  }
 catch (  TransactionFailureException e) {
    throw Transactions.propagate(e,IOException.class,ArtifactNotFoundException.class);
  }
}