Program: 51958
Project: 51958
Buggy source:
/** 
 * Command to create an EPerson. 
 */
private static int cmdAdd(Context context,String[] argv) throws AuthorizeException, SQLException {
  Options options=new Options();
  options.addOption(VERB_ADD);
  final OptionGroup identityOptions=new OptionGroup();
  identityOptions.addOption(OPT_EMAIL);
  identityOptions.addOption(OPT_NETID);
  options.addOptionGroup(identityOptions);
  options.addOption(OPT_GIVENNAME);
  options.addOption(OPT_SURNAME);
  options.addOption(OPT_PHONE);
  options.addOption(OPT_LANGUAGE);
  options.addOption(OPT_REQUIRE_CERTIFICATE);
  Option option=new Option("String_Node_Str","String_Node_Str",true,"String_Node_Str");
  options.addOption(option);
  options.addOption("String_Node_Str","String_Node_Str",false,"String_Node_Str");
  GnuParser parser=new GnuParser();
  CommandLine command;
  try {
    command=parser.parse(options,argv);
  }
 catch (  ParseException e) {
    System.err.println(e.getMessage());
    return 1;
  }
  if (command.hasOption('h')) {
    new HelpFormatter().printHelp("String_Node_Str",options);
    return 0;
  }
  if ((!command.hasOption(OPT_EMAIL.getOpt())) && (!command.hasOption(OPT_NETID.getOpt()))) {
    System.err.println("String_Node_Str");
    return 1;
  }
  if (!command.hasOption('p')) {
    System.err.println("String_Node_Str");
    return 1;
  }
  EPerson eperson=null;
  try {
    eperson=ePersonService.create(context);
  }
 catch (  SQLException ex) {
    context.abort();
    System.err.println(ex.getMessage());
    return 1;
  }
catch (  AuthorizeException ex) {
  }
  eperson.setCanLogIn(true);
  eperson.setSelfRegistered(false);
  eperson.setEmail(command.getOptionValue(OPT_EMAIL.getOpt()));
  eperson.setFirstName(context,command.getOptionValue(OPT_GIVENNAME.getOpt()));
  eperson.setLastName(context,command.getOptionValue(OPT_SURNAME.getOpt()));
  eperson.setLanguage(context,command.getOptionValue(OPT_LANGUAGE.getOpt(),Locale.getDefault().getLanguage()));
  ePersonService.setMetadata(context,eperson,"String_Node_Str",command.getOptionValue(OPT_PHONE.getOpt()));
  eperson.setNetid(command.getOptionValue(OPT_NETID.getOpt()));
  ePersonService.setPassword(eperson,command.getOptionValue('p'));
  if (command.hasOption(OPT_REQUIRE_CERTIFICATE.getOpt())) {
    eperson.setRequireCertificate(Boolean.valueOf(command.getOptionValue(OPT_REQUIRE_CERTIFICATE.getOpt())));
  }
 else {
    eperson.setRequireCertificate(false);
  }
  try {
    ePersonService.update(context,eperson);
    context.complete();
    System.out.printf("String_Node_Str",eperson.getID());
  }
 catch (  SQLException ex) {
    context.abort();
    System.err.println(ex.getMessage());
    return 1;
  }
catch (  AuthorizeException ex) {
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * Command to create an EPerson. 
 */
private static int cmdAdd(Context context,String[] argv) throws AuthorizeException, SQLException {
  Options options=new Options();
  options.addOption(VERB_ADD);
  final OptionGroup identityOptions=new OptionGroup();
  identityOptions.addOption(OPT_EMAIL);
  identityOptions.addOption(OPT_NETID);
  options.addOptionGroup(identityOptions);
  options.addOption(OPT_GIVENNAME);
  options.addOption(OPT_SURNAME);
  options.addOption(OPT_PHONE);
  options.addOption(OPT_LANGUAGE);
  options.addOption(OPT_REQUIRE_CERTIFICATE);
  Option option=new Option("String_Node_Str","String_Node_Str",true,"String_Node_Str");
  options.addOption(option);
  options.addOption("String_Node_Str","String_Node_Str",false,"String_Node_Str");
  GnuParser parser=new GnuParser();
  CommandLine command;
  try {
    command=parser.parse(options,argv);
  }
 catch (  ParseException e) {
    System.err.println(e.getMessage());
    return 1;
  }
  if (command.hasOption('h')) {
    new HelpFormatter().printHelp("String_Node_Str",options);
    return 0;
  }
  if ((!command.hasOption(OPT_EMAIL.getOpt())) && (!command.hasOption(OPT_NETID.getOpt()))) {
    System.err.println("String_Node_Str");
    return 1;
  }
  if (!command.hasOption('p')) {
    System.err.println("String_Node_Str");
    return 1;
  }
  EPerson eperson=null;
  try {
    eperson=ePersonService.create(context);
  }
 catch (  SQLException ex) {
    context.abort();
    System.err.println(ex.getMessage());
    return 1;
  }
catch (  AuthorizeException ex) {
  }
  eperson.setCanLogIn(true);
  eperson.setSelfRegistered(false);
  eperson.setEmail(command.getOptionValue(OPT_EMAIL.getOpt()));
  eperson.setFirstName(context,command.getOptionValue(OPT_GIVENNAME.getOpt()));
  eperson.setLastName(context,command.getOptionValue(OPT_SURNAME.getOpt()));
  eperson.setLanguage(context,command.getOptionValue(OPT_LANGUAGE.getOpt(),Locale.getDefault().getLanguage()));
  ePersonService.setMetadata(context,eperson,"String_Node_Str",command.getOptionValue(OPT_PHONE.getOpt()));
  eperson.setNetid(command.getOptionValue(OPT_NETID.getOpt()));
  ePersonService.setPassword(eperson,command.getOptionValue('p'));
  if (command.hasOption(OPT_REQUIRE_CERTIFICATE.getOpt())) {
    eperson.setRequireCertificate(Boolean.valueOf(command.getOptionValue(OPT_REQUIRE_CERTIFICATE.getOpt())));
  }
 else {
    eperson.setRequireCertificate(false);
  }
  try {
    ePersonService.update(context,eperson);
    context.complete();
    System.out.printf("String_Node_Str",eperson.getID().toString());
  }
 catch (  SQLException ex) {
    context.abort();
    System.err.println(ex.getMessage());
    return 1;
  }
catch (  AuthorizeException ex) {
  }
  return 0;
}