Program: 52024
Project: 52024
Buggy source:
public void run(){
  Context context=null;
  String importDir=null;
  EPerson eperson=null;
  try {
    context=new Context();
    eperson=EPerson.find(context,oldEPerson.getID());
    context.setCurrentUser(eperson);
    context.setIgnoreAuthorization(true);
    boolean isResume=theResumeDir != null;
    List<Collection> collectionList=new ArrayList<Collection>();
    if (theOtherCollections != null) {
      for (      String colID : theOtherCollections) {
        int colId=Integer.parseInt(colID);
        if (colId != theOwningCollection.getID()) {
          Collection col=Collection.find(context,colId);
          if (col != null) {
            collectionList.add(col);
          }
        }
      }
    }
    Collection[] otherCollections=collectionList.toArray(new Collection[collectionList.size()]);
    importDir=ConfigurationManager.getProperty("String_Node_Str") + File.separator + "String_Node_Str"+ File.separator+ context.getCurrentUser().getID()+ File.separator+ (isResume ? theResumeDir : (new GregorianCalendar()).getTimeInMillis());
    File importDirFile=new File(importDir);
    if (!importDirFile.exists()) {
      boolean success=importDirFile.mkdirs();
      if (!success) {
        log.info("String_Node_Str");
        throw new Exception("String_Node_Str");
      }
    }
    String dataPath=null;
    String dataDir=null;
    if (theInputType.equals("String_Node_Str")) {
      dataPath=importDirFile + File.separator + "String_Node_Str";
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
 else     if (theInputType.equals("String_Node_Str")) {
      FileUtils.copyFileToDirectory(new File(theFilePath),importDirFile);
      dataPath=importDirFile + File.separator + (new File(theFilePath)).getName();
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
 else {
      dataPath=importDirFile + File.separator + (new File(theFilePath)).getName();
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
    if (isResume) {
      (new File(dataPath)).delete();
      FileDeleteStrategy.FORCE.delete(new File(dataDir));
    }
    String sourcePath=null;
    if (theInputType.equals("String_Node_Str")) {
      OutputStream os=new FileOutputStream(dataPath);
      byte[] b=new byte[2048];
      int length;
      InputStream is=new URL(theFilePath).openStream();
      while ((length=is.read(b)) != -1) {
        os.write(b,0,length);
      }
      is.close();
      os.close();
      sourcePath=unzip(new File(dataPath),dataDir);
      FileUtils.moveDirectory(new File(sourcePath),new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
      FileDeleteStrategy.FORCE.delete(new File(dataDir));
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
 else     if (theInputType.equals("String_Node_Str")) {
      sourcePath=unzip(new File(dataPath),dataDir);
      FileUtils.moveDirectory(new File(sourcePath),new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
      FileDeleteStrategy.FORCE.delete(new File(dataDir));
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
    String mapFilePath=importDirFile + File.separator + "String_Node_Str";
    Collection[] finalCollections=null;
    if (theOwningCollection != null) {
      finalCollections=new Collection[otherCollections.length + 1];
      finalCollections[0]=theOwningCollection;
      for (int i=0; i < otherCollections.length; i++) {
        finalCollections[i + 1]=otherCollections[i];
      }
    }
    ItemImport myloader=new ItemImport();
    myloader.isResume=isResume;
    if (theInputType.equals("String_Node_Str") || theInputType.equals("String_Node_Str")) {
      myloader.addItems(context,finalCollections,dataDir,mapFilePath,template);
    }
 else {
      myloader.addBTEItems(context,finalCollections,theFilePath,mapFilePath,template,theInputType,dataDir);
    }
    emailSuccessMessage(context,eperson,mapFilePath);
    context.complete();
  }
 catch (  Exception e) {
    e.printStackTrace();
    String exceptionString=ExceptionUtils.getStackTrace(e);
    if (mapOut != null) {
      mapOut.close();
    }
    mapOut=null;
    try {
      File importDirFile=new File(importDir + File.separator + "String_Node_Str");
      PrintWriter errorWriter=new PrintWriter(importDirFile);
      errorWriter.print(exceptionString);
      errorWriter.close();
      emailErrorMessage(eperson,exceptionString);
      throw new Exception(e.getMessage());
    }
 catch (    Exception e2) {
    }
  }
 finally {
    if (mapOut != null) {
      mapOut.close();
    }
    try {
      context.complete();
    }
 catch (    SQLException sqle) {
      context.abort();
    }
  }
}

Fixed version (ground truth):
public void run(){
  Context context=null;
  String importDir=null;
  EPerson eperson=null;
  try {
    context=new Context();
    eperson=EPerson.find(context,oldEPerson.getID());
    context.setCurrentUser(eperson);
    context.setIgnoreAuthorization(true);
    boolean isResume=theResumeDir != null;
    List<Collection> collectionList=new ArrayList<Collection>();
    if (theOtherCollections != null) {
      for (      String colID : theOtherCollections) {
        int colId=Integer.parseInt(colID);
        if (colId != theOwningCollection.getID()) {
          Collection col=Collection.find(context,colId);
          if (col != null) {
            collectionList.add(col);
          }
        }
      }
    }
    Collection[] otherCollections=collectionList.toArray(new Collection[collectionList.size()]);
    importDir=ConfigurationManager.getProperty("String_Node_Str") + File.separator + "String_Node_Str"+ File.separator+ context.getCurrentUser().getID()+ File.separator+ (isResume ? theResumeDir : (new GregorianCalendar()).getTimeInMillis());
    File importDirFile=new File(importDir);
    if (!importDirFile.exists()) {
      boolean success=importDirFile.mkdirs();
      if (!success) {
        log.info("String_Node_Str");
        throw new Exception("String_Node_Str");
      }
    }
    String dataPath=null;
    String dataDir=null;
    if (theInputType.equals("String_Node_Str")) {
      dataPath=importDirFile + File.separator + "String_Node_Str";
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
 else     if (theInputType.equals("String_Node_Str")) {
      FileUtils.copyFileToDirectory(new File(theFilePath),importDirFile);
      dataPath=importDirFile + File.separator + (new File(theFilePath)).getName();
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
 else {
      dataPath=importDirFile + File.separator + (new File(theFilePath)).getName();
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
    if (isResume) {
      if (!theInputType.equals("String_Node_Str")) {
        (new File(dataPath)).delete();
      }
      (new File(importDirFile + File.separator + "String_Node_Str")).delete();
      FileDeleteStrategy.FORCE.delete(new File(dataDir));
      FileDeleteStrategy.FORCE.delete(new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
    }
    String sourcePath=null;
    if (theInputType.equals("String_Node_Str")) {
      OutputStream os=new FileOutputStream(dataPath);
      byte[] b=new byte[2048];
      int length;
      InputStream is=new URL(theFilePath).openStream();
      while ((length=is.read(b)) != -1) {
        os.write(b,0,length);
      }
      is.close();
      os.close();
      sourcePath=unzip(new File(dataPath),dataDir);
      FileUtils.moveDirectory(new File(sourcePath),new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
      FileDeleteStrategy.FORCE.delete(new File(dataDir));
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
 else     if (theInputType.equals("String_Node_Str")) {
      sourcePath=unzip(new File(dataPath),dataDir);
      FileUtils.moveDirectory(new File(sourcePath),new File(importDirFile + File.separator + "String_Node_Str"+ File.separator));
      FileDeleteStrategy.FORCE.delete(new File(dataDir));
      dataDir=importDirFile + File.separator + "String_Node_Str"+ File.separator;
    }
    String mapFilePath=importDirFile + File.separator + "String_Node_Str";
    Collection[] finalCollections=null;
    if (theOwningCollection != null) {
      finalCollections=new Collection[otherCollections.length + 1];
      finalCollections[0]=theOwningCollection;
      for (int i=0; i < otherCollections.length; i++) {
        finalCollections[i + 1]=otherCollections[i];
      }
    }
    ItemImport myloader=new ItemImport();
    myloader.isResume=isResume;
    if (theInputType.equals("String_Node_Str") || theInputType.equals("String_Node_Str")) {
      myloader.addItems(context,finalCollections,dataDir,mapFilePath,template);
    }
 else {
      myloader.addBTEItems(context,finalCollections,theFilePath,mapFilePath,template,theInputType,dataDir);
    }
    emailSuccessMessage(context,eperson,mapFilePath);
    context.complete();
  }
 catch (  Exception e) {
    e.printStackTrace();
    String exceptionString=ExceptionUtils.getStackTrace(e);
    if (mapOut != null) {
      mapOut.close();
    }
    mapOut=null;
    try {
      File importDirFile=new File(importDir + File.separator + "String_Node_Str");
      PrintWriter errorWriter=new PrintWriter(importDirFile);
      errorWriter.print(exceptionString);
      errorWriter.close();
      emailErrorMessage(eperson,exceptionString);
      throw new Exception(e.getMessage());
    }
 catch (    Exception e2) {
    }
  }
 finally {
    if (mapOut != null) {
      mapOut.close();
    }
    try {
      context.complete();
    }
 catch (    SQLException sqle) {
      context.abort();
    }
  }
}