Program: 5513
Project: 5513
Buggy source:
/** 
 * Deletes all modules in a namespace, other than system. Presumes that the namespace has already been checked to be non-system.
 * @param namespaceId the {@link NamespaceId} to delete modules from.
 */
public void deleteModules(final NamespaceId namespaceId) throws DatasetModuleConflictException {
  Preconditions.checkArgument(namespaceId != null && !NamespaceId.SYSTEM.equals(namespaceId),"String_Node_Str");
  LOG.warn("String_Node_Str",namespaceId);
  try {
    final DatasetTypeMDS datasetTypeMDS=datasetCache.getDataset(DatasetMetaTableUtil.META_TABLE_NAME);
    final DatasetInstanceMDS datasetInstanceMDS=datasetCache.getDataset(DatasetMetaTableUtil.INSTANCE_TABLE_NAME);
    txExecutorFactory.createExecutor(datasetCache).execute(new TransactionExecutor.Subroutine(){
      @Override public void apply() throws DatasetModuleConflictException, IOException {
        final Set<String> typesToDelete=new HashSet<String>();
        final List<Location> moduleLocations=new ArrayList<>();
        final Collection<DatasetModuleMeta> modules=datasetTypeMDS.getModules(namespaceId);
        try {
          impersonator.doAs(namespaceId,new Callable<Void>(){
            @Override public Void call() throws Exception {
              for (              DatasetModuleMeta module : modules) {
                typesToDelete.addAll(module.getTypes());
                moduleLocations.add(locationFactory.create(module.getJarLocation()));
              }
              return null;
            }
          }
);
        }
 catch (        Exception e) {
          Throwables.propagate(e);
        }
        Collection<DatasetSpecification> instances=datasetInstanceMDS.getByTypes(namespaceId,typesToDelete);
        if (!instances.isEmpty()) {
          throw new DatasetModuleConflictException("String_Node_Str");
        }
        datasetTypeMDS.deleteModules(namespaceId);
        for (        Location moduleLocation : moduleLocations) {
          if (!moduleLocation.delete()) {
            LOG.debug("String_Node_Str",moduleLocation);
          }
        }
      }
    }
);
  }
 catch (  TransactionFailureException e) {
    if (e.getCause() != null && e.getCause() instanceof DatasetModuleConflictException) {
      throw (DatasetModuleConflictException)e.getCause();
    }
    LOG.error("String_Node_Str",namespaceId);
    throw Throwables.propagate(e);
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw Throwables.propagate(e);
  }
}

Fixed version (ground truth):
/** 
 * Deletes all modules in a namespace, other than system. Presumes that the namespace has already been checked to be non-system.
 * @param namespaceId the {@link NamespaceId} to delete modules from.
 */
public void deleteModules(final NamespaceId namespaceId) throws DatasetModuleConflictException {
  Preconditions.checkArgument(namespaceId != null && !NamespaceId.SYSTEM.equals(namespaceId),"String_Node_Str");
  LOG.warn("String_Node_Str",namespaceId);
  try {
    final DatasetTypeMDS datasetTypeMDS=datasetCache.getDataset(DatasetMetaTableUtil.META_TABLE_NAME);
    final DatasetInstanceMDS datasetInstanceMDS=datasetCache.getDataset(DatasetMetaTableUtil.INSTANCE_TABLE_NAME);
    txExecutorFactory.createExecutor(datasetCache).execute(new TransactionExecutor.Subroutine(){
      @Override public void apply() throws DatasetModuleConflictException, IOException {
        final Set<String> typesToDelete=new HashSet<String>();
        final List<Location> moduleLocations=new ArrayList<>();
        final Collection<DatasetModuleMeta> modules=datasetTypeMDS.getModules(namespaceId);
        try {
          impersonator.doAs(namespaceId,new Callable<Void>(){
            @Override public Void call() throws Exception {
              for (              DatasetModuleMeta module : modules) {
                typesToDelete.addAll(module.getTypes());
                moduleLocations.add(Locations.getLocationFromAbsolutePath(locationFactory,module.getJarLocationPath()));
              }
              return null;
            }
          }
);
        }
 catch (        Exception e) {
          Throwables.propagate(e);
        }
        Collection<DatasetSpecification> instances=datasetInstanceMDS.getByTypes(namespaceId,typesToDelete);
        if (!instances.isEmpty()) {
          throw new DatasetModuleConflictException("String_Node_Str");
        }
        datasetTypeMDS.deleteModules(namespaceId);
        for (        Location moduleLocation : moduleLocations) {
          if (!moduleLocation.delete()) {
            LOG.debug("String_Node_Str",moduleLocation);
          }
        }
      }
    }
);
  }
 catch (  TransactionFailureException e) {
    if (e.getCause() != null && e.getCause() instanceof DatasetModuleConflictException) {
      throw (DatasetModuleConflictException)e.getCause();
    }
    LOG.error("String_Node_Str",namespaceId);
    throw Throwables.propagate(e);
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw Throwables.propagate(e);
  }
}