Program: 52218
Project: 52218
Buggy source:
/** 
 * Execute the DSpace script launcher
 * @param args Any parameters required to be passed to the scripts it executes
 * @throws Exception
 */
public static void main(String[] args){
  if (args.length < 1) {
    System.err.println("String_Node_Str");
    display();
    System.exit(1);
  }
  try {
    kernelImpl=DSpaceKernelInit.getKernel(null);
    if (!kernelImpl.isRunning()) {
      kernelImpl.start(ConfigurationManager.getProperty("String_Node_Str"));
    }
  }
 catch (  Exception e) {
    try {
      kernelImpl.destroy();
    }
 catch (    Exception e1) {
    }
    String message="String_Node_Str" + e.getMessage();
    System.err.println(message + "String_Node_Str" + e);
    throw new RuntimeException(message,e);
  }
  Document doc=getConfig();
  String request=args[0];
  Element root=doc.getRootElement();
  List<Element> commands=root.getChildren("String_Node_Str");
  for (  Element command : commands) {
    if (request.equalsIgnoreCase(command.getChild("String_Node_Str").getValue())) {
      List<Element> steps=command.getChildren("String_Node_Str");
      for (      Element step : steps) {
        Class target=null;
        String className=step.getChild("String_Node_Str").getValue();
        try {
          target=Class.forName(className,true,Thread.currentThread().getContextClassLoader());
        }
 catch (        ClassNotFoundException e) {
          System.err.println("String_Node_Str" + className);
          System.exit(1);
        }
        String[] useargs=args.clone();
        Class[] argTypes={useargs.getClass()};
        boolean passargs=true;
        if ((step.getAttribute("String_Node_Str") != null) && ("String_Node_Str".equalsIgnoreCase(step.getAttribute("String_Node_Str").getValue()))) {
          passargs=false;
        }
        if ((args.length == 1) || (!passargs)) {
          useargs=new String[0];
        }
 else {
          String[] argsnew=new String[useargs.length - 1];
          for (int i=1; i < useargs.length; i++) {
            argsnew[i - 1]=useargs[i];
          }
          useargs=argsnew;
        }
        List<Element> bits=step.getChildren("String_Node_Str");
        if (step.getChild("String_Node_Str") != null) {
          String[] argsnew=new String[useargs.length + bits.size()];
          int i=0;
          for (          Element arg : bits) {
            argsnew[i++]=arg.getValue();
          }
          for (; i < bits.size() + useargs.length; i++) {
            argsnew[i]=useargs[i - bits.size()];
          }
          useargs=argsnew;
        }
        RequestService requestService=kernelImpl.getServiceManager().getServiceByName(RequestService.class.getName(),RequestService.class);
        if (requestService == null) {
          throw new IllegalStateException("String_Node_Str");
        }
        requestService.startRequest();
        try {
          Object[] arguments={useargs};
          Method main=target.getMethod("String_Node_Str",argTypes);
          Object output=main.invoke(null,arguments);
          requestService.endRequest(null);
        }
 catch (        Exception e) {
          requestService.endRequest(e);
          if (kernelImpl != null) {
            kernelImpl.destroy();
            kernelImpl=null;
          }
          System.err.println("String_Node_Str" + e.getMessage());
          System.exit(1);
        }
      }
      if (kernelImpl != null) {
        kernelImpl.destroy();
        kernelImpl=null;
      }
      System.exit(0);
    }
  }
  if (kernelImpl != null) {
    kernelImpl.destroy();
    kernelImpl=null;
  }
  System.err.println("String_Node_Str" + args[0]);
  display();
  System.exit(1);
}

Fixed version (ground truth):
/** 
 * Execute the DSpace script launcher
 * @param args Any parameters required to be passed to the scripts it executes
 * @throws Exception
 */
public static void main(String[] args){
  if (args.length < 1) {
    System.err.println("String_Node_Str");
    display();
    System.exit(1);
  }
  try {
    kernelImpl=DSpaceKernelInit.getKernel(null);
    if (!kernelImpl.isRunning()) {
      kernelImpl.start(ConfigurationManager.getProperty("String_Node_Str"));
    }
  }
 catch (  Exception e) {
    try {
      kernelImpl.destroy();
    }
 catch (    Exception e1) {
    }
    String message="String_Node_Str" + e.getMessage();
    System.err.println(message + "String_Node_Str" + e);
    throw new RuntimeException(message,e);
  }
  Document doc=getConfig();
  String request=args[0];
  Element root=doc.getRootElement();
  List<Element> commands=root.getChildren("String_Node_Str");
  for (  Element command : commands) {
    if (request.equalsIgnoreCase(command.getChild("String_Node_Str").getValue())) {
      List<Element> steps=command.getChildren("String_Node_Str");
      for (      Element step : steps) {
        Class target=null;
        String className=step.getChild("String_Node_Str").getValue();
        try {
          target=Class.forName(className,true,Thread.currentThread().getContextClassLoader());
        }
 catch (        ClassNotFoundException e) {
          System.err.println("String_Node_Str" + className);
          System.exit(1);
        }
        String[] useargs=args.clone();
        Class[] argTypes={useargs.getClass()};
        boolean passargs=true;
        if ((step.getAttribute("String_Node_Str") != null) && ("String_Node_Str".equalsIgnoreCase(step.getAttribute("String_Node_Str").getValue()))) {
          passargs=false;
        }
        if ((args.length == 1) || (!passargs)) {
          useargs=new String[0];
        }
 else {
          String[] argsnew=new String[useargs.length - 1];
          for (int i=1; i < useargs.length; i++) {
            argsnew[i - 1]=useargs[i];
          }
          useargs=argsnew;
        }
        List<Element> bits=step.getChildren("String_Node_Str");
        if (step.getChild("String_Node_Str") != null) {
          String[] argsnew=new String[useargs.length + bits.size()];
          int i=0;
          for (          Element arg : bits) {
            argsnew[i++]=arg.getValue();
          }
          for (; i < bits.size() + useargs.length; i++) {
            argsnew[i]=useargs[i - bits.size()];
          }
          useargs=argsnew;
        }
        RequestService requestService=kernelImpl.getServiceManager().getServiceByName(RequestService.class.getName(),RequestService.class);
        if (requestService == null) {
          throw new IllegalStateException("String_Node_Str");
        }
        requestService.startRequest();
        try {
          Object[] arguments={useargs};
          Method main=target.getMethod("String_Node_Str",argTypes);
          Object output=main.invoke(null,arguments);
          requestService.endRequest(null);
        }
 catch (        Exception e) {
          requestService.endRequest(e);
          if (kernelImpl != null) {
            kernelImpl.destroy();
            kernelImpl=null;
          }
          Throwable cause=e.getCause();
          System.err.println("String_Node_Str" + cause.getMessage());
          cause.printStackTrace();
          System.exit(1);
        }
      }
      if (kernelImpl != null) {
        kernelImpl.destroy();
        kernelImpl=null;
      }
      System.exit(0);
    }
  }
  if (kernelImpl != null) {
    kernelImpl.destroy();
    kernelImpl=null;
  }
  System.err.println("String_Node_Str" + args[0]);
  display();
  System.exit(1);
}