Program: 52010
Project: 52010
Buggy source:
/** 
 * Recursively create one or more DSpace Objects out of the contents of the ingested package (and all other referenced packages). The initial object is created under the indicated parent.  All other objects are created based on their relationship to the initial object. <p> For example, a scenario may be to create a Collection based on a collection-level package, and also create an Item for every item-level package referenced by the collection-level package. <p> The output of this method is one or more newly created <code>DspaceObject<code>s. <p> The packager <em>may</em> choose not to implement <code>ingestAll</code>, or simply forward the call to <code>ingest</code> if it is unable to support recursive ingestion. <p> The deposit license (Only significant for Item) is passed explicitly as a string since there is no place for it in many package formats.  It is optional and may be given as <code>null</code>.
 * @param context  DSpace context.
 * @param parent parent under which to create the initial object(may be null -- in which case ingester must determine parent from package or throw an error).
 * @param pkgFile  The initial package file to ingest
 * @param params Properties-style list of options (interpreted by each packager).
 * @param license  may be null, which takes default license.
 * @return List of DSpaceObjects created
 * @throws PackageValidationException if initial package (or any referenced package)is unacceptable or there is a fatal error in creating a DSpaceObject
 * @throws UnsupportedOperationException if this packager does notimplement <code>ingestAll</code>
 */
@Override public List<DSpaceObject> ingestAll(Context context,DSpaceObject parent,File pkgFile,PackageParameters params,String license) throws PackageException, UnsupportedOperationException, CrosswalkException, AuthorizeException, SQLException, IOException {
  if (!params.recursiveModeEnabled()) {
    params.setRecursiveModeEnabled(true);
  }
  DSpaceObject dso=null;
  try {
    dso=ingest(context,parent,pkgFile,params,license);
  }
 catch (  IllegalStateException ie) {
    if (params.keepExistingModeEnabled()) {
      log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + pkgFile));
    }
 else {
      throw ie;
    }
  }
  if (dso != null) {
    addToIngestedList(dso);
    if (dso.getType() != Constants.ITEM) {
      List<String> childPkgRefs=getPackageReferences(dso);
      if (childPkgRefs != null && !childPkgRefs.isEmpty()) {
        for (        String childPkgRef : childPkgRefs) {
          int oldSize=dsoIngestedList.size();
          File childPkg=new File(pkgFile.getAbsoluteFile().getParent(),childPkgRef);
          ingestAll(context,dso,childPkg,params,license);
          if (Constants.COLLECTION == dso.getType() && dsoIngestedList.size() > oldSize) {
            Item childItem=(Item)dsoIngestedList.get(oldSize);
            Collection collection=(Collection)dso;
            if (!childItem.isIn(collection)) {
              collection.addItem(childItem);
            }
          }
        }
      }
    }
  }
  return getIngestedList();
}

Fixed version (ground truth):
/** 
 * Recursively create one or more DSpace Objects out of the contents of the ingested package (and all other referenced packages). The initial object is created under the indicated parent.  All other objects are created based on their relationship to the initial object. <p> For example, a scenario may be to create a Collection based on a collection-level package, and also create an Item for every item-level package referenced by the collection-level package. <p> The output of this method is one or more newly created <code>DspaceObject<code>s. <p> The packager <em>may</em> choose not to implement <code>ingestAll</code>, or simply forward the call to <code>ingest</code> if it is unable to support recursive ingestion. <p> The deposit license (Only significant for Item) is passed explicitly as a string since there is no place for it in many package formats.  It is optional and may be given as <code>null</code>.
 * @param context  DSpace context.
 * @param parent parent under which to create the initial object(may be null -- in which case ingester must determine parent from package or throw an error).
 * @param pkgFile  The initial package file to ingest
 * @param params Properties-style list of options (interpreted by each packager).
 * @param license  may be null, which takes default license.
 * @return List of DSpaceObjects created
 * @throws PackageValidationException if initial package (or any referenced package)is unacceptable or there is a fatal error in creating a DSpaceObject
 * @throws UnsupportedOperationException if this packager does notimplement <code>ingestAll</code>
 */
@Override public List<DSpaceObject> ingestAll(Context context,DSpaceObject parent,File pkgFile,PackageParameters params,String license) throws PackageException, UnsupportedOperationException, CrosswalkException, AuthorizeException, SQLException, IOException {
  if (!params.recursiveModeEnabled()) {
    params.setRecursiveModeEnabled(true);
  }
  DSpaceObject dso=null;
  if (!getIngestedMap().containsKey(pkgFile)) {
    try {
      dso=ingest(context,parent,pkgFile,params,license);
    }
 catch (    IllegalStateException ie) {
      if (params.keepExistingModeEnabled()) {
        log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + pkgFile.getName()));
      }
 else {
        throw ie;
      }
    }
  }
 else {
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + pkgFile.getName()));
  }
  if (dso != null) {
    addToIngestedMap(pkgFile,dso);
    if (dso.getType() != Constants.ITEM) {
      List<String> childPkgRefs=getPackageReferences(dso);
      if (childPkgRefs != null && !childPkgRefs.isEmpty()) {
        for (        String childPkgRef : childPkgRefs) {
          File childPkg=new File(pkgFile.getAbsoluteFile().getParent(),childPkgRef);
          ingestAll(context,null,childPkg,params,license);
          if (Constants.COLLECTION == dso.getType()) {
            Item childItem=(Item)getIngestedMap().get(childPkg);
            Collection collection=(Collection)dso;
            if (childItem != null && !childItem.isIn(collection)) {
              collection.addItem(childItem);
            }
          }
        }
      }
    }
  }
  return getIngestedList();
}