nus-yam/ex-repair huggingface dataset:
Program: 28276
Project: 28276
Buggy source:
/** 
 * <p> This handler filters out AdminObjects from a list-jms-resources, only return Connection Factories.
 */
@Handler(id="String_Node_Str") public static List filterAdminObjects(HandlerContext context){
  List result=new ArrayList();
  FilterTreeEvent event=null;
  try {
    if (context.getEventObject() instanceof FilterTreeEvent) {
      event=(FilterTreeEvent)context.getEventObject();
    }
 else {
      return result;
    }
    List<String> jmsResources=event.getChildObjects();
    if (jmsResources == null || jmsResources.size() <= 0) {
      return result;
    }
    List adminObjs=new ArrayList();
    Map responseMap=RestUtil.restRequest(GuiUtil.getSessionValue("String_Node_Str") + "String_Node_Str",null,"String_Node_Str",null,false);
    Map<String,Object> extraPropsMap=(Map<String,Object>)((Map<String,Object>)responseMap.get("String_Node_Str")).get("String_Node_Str");
    if (extraPropsMap != null) {
      Map<String,Object> childRes=(Map<String,Object>)extraPropsMap.get("String_Node_Str");
      if (childRes != null) {
        adminObjs=new ArrayList(childRes.keySet());
      }
    }
    for (    String oneJms : jmsResources) {
      if (!adminObjs.contains(oneJms)) {
        result.add(oneJms);
      }
    }
  }
 catch (  Exception ex) {
    GuiUtil.getLogger().warning("String_Node_Str");
  }
  return result;
}

Fixed version (ground truth):
/** 
 * <p> This handler filters out AdminObjects from a list-jms-resources, only return Connection Factories.
 */
@Handler(id="String_Node_Str") public static List filterAdminObjects(HandlerContext context){
  List result=new ArrayList();
  FilterTreeEvent event=null;
  try {
    if (context.getEventObject() instanceof FilterTreeEvent) {
      event=FilterTreeEvent.class.cast(context.getEventObject());
    }
 else {
      return result;
    }
    List<String> jmsResources=event.getChildObjects();
    if (jmsResources == null || jmsResources.size() <= 0) {
      return result;
    }
    List adminObjs=new ArrayList();
    Map responseMap=RestUtil.restRequest(GuiUtil.getSessionValue("String_Node_Str") + "String_Node_Str",null,"String_Node_Str",null,false);
    Map<String,Object> extraPropsMap=(Map<String,Object>)((Map<String,Object>)responseMap.get("String_Node_Str")).get("String_Node_Str");
    if (extraPropsMap != null) {
      Map<String,Object> childRes=(Map<String,Object>)extraPropsMap.get("String_Node_Str");
      if (childRes != null) {
        adminObjs=new ArrayList(childRes.keySet());
      }
    }
    for (    String oneJms : jmsResources) {
      if (!adminObjs.contains(oneJms)) {
        result.add(oneJms);
      }
    }
  }
 catch (  Exception ex) {
    GuiUtil.getLogger().warning("String_Node_Str");
  }
  return result;
}
Program: 28279
Project: 28279
Buggy source:
protected static MultivaluedMap buildMultivalueMap(Map<String,Object> payload){
  MultivaluedMap formData=new MultivaluedHashMap();
  if (payload == null || payload.isEmpty()) {
    return formData;
  }
  for (  final Map.Entry<String,Object> entry : payload.entrySet()) {
    final Object value=entry.getValue();
    final String key=entry.getKey();
    if (value instanceof Collection) {
      for (      Object obj : ((Collection)value)) {
        try {
          formData.add(key,obj);
        }
 catch (        ClassCastException ex) {
          Logger logger=GuiUtil.getLogger();
          if (logger.isLoggable(Level.FINEST)) {
            logger.log(Level.FINEST,GuiUtil.getCommonMessage("String_Node_Str",new Object[]{key,obj}));
          }
        }
      }
    }
 else {
      try {
        formData.putSingle(key,value);
      }
 catch (      ClassCastException ex) {
        Logger logger=GuiUtil.getLogger();
        if (logger.isLoggable(Level.FINEST)) {
          logger.log(Level.FINEST,GuiUtil.getCommonMessage("String_Node_Str",new Object[]{key,value}));
        }
      }
    }
  }
  return formData;
}

Fixed version (ground truth):
protected static MultivaluedMap buildMultivalueMap(Map<String,Object> payload){
  MultivaluedMap formData=new MultivaluedHashMap();
  if (payload == null || payload.isEmpty()) {
    return formData;
  }
  for (  final Map.Entry<String,Object> entry : payload.entrySet()) {
    final Object value=entry.getValue();
    final String key=entry.getKey();
    if (value instanceof Collection) {
      for (      Object obj : ((Collection)value)) {
        try {
          formData.add(key,obj);
        }
 catch (        ClassCastException ex) {
          Logger logger=GuiUtil.getLogger();
          if (logger.isLoggable(Level.FINEST)) {
            logger.log(Level.FINEST,GuiUtil.getCommonMessage("String_Node_Str",new Object[]{key,obj}));
          }
        }
      }
    }
 else {
      try {
        if (key.equals("String_Node_Str")) {
          System.out.println("String_Node_Str");
        }
        formData.putSingle(key,value);
      }
 catch (      ClassCastException ex) {
        Logger logger=GuiUtil.getLogger();
        if (logger.isLoggable(Level.FINEST)) {
          logger.log(Level.FINEST,GuiUtil.getCommonMessage("String_Node_Str",new Object[]{key,value}));
        }
      }
    }
  }
  return formData;
}
Program: 28281
Project: 28281
Buggy source:
/** 
 */
@Override protected int executeCommand() throws CommandException, CommandValidationException {
  int exitCode=-1;
  if (node == null) {
    if (nodeDirChild == null)     throw new CommandException(Strings.get("String_Node_Str","String_Node_Str" + "String_Node_Str"));
    _node=nodeDirChild.getName();
    String nodeHost=getInstanceHostName(true);
    createNodeImplicit(_node,getProductRootPath(),nodeHost);
  }
 else {
    _node=node;
  }
  if (isRegisteredToDAS()) {
    if (!_rendezvousOccurred) {
      setRendezvousOccurred("String_Node_Str");
      _rendezvousOccurred=true;
    }
  }
 else {
    if (instanceName != null && instanceDir != null) {
      validateInstanceDirUnique();
    }
    try {
      registerToDAS();
      _rendezvousOccurred=true;
    }
 catch (    CommandException ce) {
      FileUtils.deleteFileNowOrLater(instanceDir);
      throw ce;
    }
  }
  bootstrapSecureAdminFiles();
  try {
    exitCode=super.executeCommand();
    if (exitCode == SUCCESS) {
      saveMasterPassword();
    }
  }
 catch (  CommandException ce) {
    String msg="String_Node_Str" + instanceName;
    if (ce.getLocalizedMessage() != null) {
      msg=msg + "String_Node_Str" + ce.getLocalizedMessage();
    }
    logger.severe(msg);
    setRendezvousOccurred("String_Node_Str");
    _rendezvousOccurred=false;
    throw new CommandException(msg,ce);
  }
  return exitCode;
}

Fixed version (ground truth):
/** 
 */
@Override protected int executeCommand() throws CommandException, CommandValidationException {
  int exitCode=-1;
  if (node == null) {
    if (nodeDirChild == null)     throw new CommandException(Strings.get("String_Node_Str","String_Node_Str" + "String_Node_Str"));
    _node=nodeDirChild.getName();
    String nodeHost=getInstanceHostName(true);
    createNodeImplicit(_node,getProductRootPath(),nodeHost);
  }
 else {
    _node=node;
  }
  if (isRegisteredToDAS()) {
    if (!_rendezvousOccurred) {
      setRendezvousOccurred("String_Node_Str");
      _rendezvousOccurred=true;
    }
  }
 else {
    validateInstanceDirUnique();
    try {
      registerToDAS();
      _rendezvousOccurred=true;
    }
 catch (    CommandException ce) {
      FileUtils.deleteFileNowOrLater(instanceDir);
      throw ce;
    }
  }
  bootstrapSecureAdminFiles();
  try {
    exitCode=super.executeCommand();
    if (exitCode == SUCCESS) {
      saveMasterPassword();
    }
  }
 catch (  CommandException ce) {
    String msg="String_Node_Str" + instanceName;
    if (ce.getLocalizedMessage() != null) {
      msg=msg + "String_Node_Str" + ce.getLocalizedMessage();
    }
    logger.severe(msg);
    setRendezvousOccurred("String_Node_Str");
    _rendezvousOccurred=false;
    throw new CommandException(msg,ce);
  }
  return exitCode;
}
Program: 28282
Project: 28282
Buggy source:
private void validateInstanceDirUnique() throws CommandException {
  RemoteCLICommand rc=new RemoteCLICommand("String_Node_Str",this.programOpts,this.env);
  String returnOutput=rc.executeAndReturnOutput("String_Node_Str","String_Node_Str",_node);
  if (returnOutput == null)   return;
  String[] registeredInstanceNamesOnThisNode=returnOutput.split("String_Node_Str");
  for (  String registeredInstanceName : registeredInstanceNamesOnThisNode) {
    File instanceListDir=new File(nodeDirChild,registeredInstanceName);
    if (instanceName.equalsIgnoreCase(registeredInstanceName) && instanceDir.equals(instanceListDir)) {
      throw new CommandException(Strings.get("String_Node_Str",instanceName,registeredInstanceName));
    }
  }
}

Fixed version (ground truth):
private void validateInstanceDirUnique() throws CommandException {
  RemoteCLICommand rc=new RemoteCLICommand("String_Node_Str",this.programOpts,this.env);
  String returnOutput=rc.executeAndReturnOutput("String_Node_Str","String_Node_Str",_node);
  if (returnOutput == null)   return;
  String[] registeredInstanceNamesOnThisNode=returnOutput.split("String_Node_Str");
  for (  String registeredInstanceName : registeredInstanceNamesOnThisNode) {
    File instanceListDir=new File(nodeDirChild,registeredInstanceName);
    if (instanceName != null && registeredInstanceName.equalsIgnoreCase(instanceName)) {
      if (instanceDir != null && instanceListDir.equals(instanceDir)) {
        throw new CommandException(Strings.get("String_Node_Str",instanceName,registeredInstanceName));
      }
    }
  }
}
Program: 28283
Project: 28283
Buggy source:
private static String formatStringForDisplay(String strToFormat){
  String[] strs=strToFormat.split("String_Node_Str");
  StringBuilder formattedStr=new StringBuilder();
  if (strs != null && strs.length > 10) {
    for (int i=0; i < strs.length; i++) {
      String str=strs[i];
      if (!(formattedStr.length() == 0)) {
        formattedStr.append("String_Node_Str");
      }
      if (i % 10 == 0 && i != 0) {
        formattedStr.append("String_Node_Str");
      }
      formattedStr.append(str);
    }
    return formattedStr.toString();
  }
  return strToFormat;
}

Fixed version (ground truth):
private static String formatStringForDisplay(String strToFormat){
  String[] strs=strToFormat.split("String_Node_Str");
  StringBuilder formattedStr=new StringBuilder();
  if (strs.length > 10) {
    for (int i=0; i < strs.length; i++) {
      String str=strs[i];
      if (!(formattedStr.length() == 0)) {
        formattedStr.append("String_Node_Str");
      }
      if (i % 10 == 0 && i != 0) {
        formattedStr.append("String_Node_Str");
      }
      formattedStr.append(str);
    }
    return formattedStr.toString();
  }
  return strToFormat;
}
Program: 28285
Project: 28285
Buggy source:
/** 
 * Given the parent URL and the desired childType, this method will build a List of Strings that contains child entity names.
 * @param endpoint
 * @return
 * @throws Exception
 */
public static List<String> getChildList(String endpoint) throws Exception {
  List<String> childElements=new ArrayList<String>();
  Map<String,String> childResources=getChildMap(endpoint);
  if (childResources != null) {
    childElements.addAll(childResources.values());
  }
  Collections.sort(childElements);
  return childElements;
}

Fixed version (ground truth):
/** 
 * Given the parent URL and the desired childType, this method will build a List of Strings that contains child entity names.
 * @param endpoint
 * @return
 * @throws Exception
 */
public static List<String> getChildList(String endpoint) throws Exception {
  List<String> childElements=new ArrayList<String>();
  Map<String,String> childResources=getChildMap(endpoint);
  childElements.addAll(childResources.values());
  Collections.sort(childElements);
  return childElements;
}
Program: 28287
Project: 28287
Buggy source:
/** 
 * <p> This handler filters out not required protocols from the list of protocols available
 */
@Handler(id="String_Node_Str") public static List filterProtocols(HandlerContext context){
  FilterTreeEvent event=(FilterTreeEvent)context.getEventObject();
  List protocols=event.getChildObjects();
  ArrayList result=new ArrayList();
  if (protocols != null && protocols.size() > 0) {
    for (int i=0; i < protocols.size(); i++) {
      String protocol=(String)protocols.get(i);
      if (!(protocol.equals(ServerTags.PORT_UNIF_PROTOCOL_NAME) || protocol.equals(ServerTags.REDIRECT_PROTOCOL_NAME))) {
        result.add(protocol);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * <p> This handler filters out not required protocols from the list of protocols available
 */
@Handler(id="String_Node_Str") public static List filterProtocols(HandlerContext context){
  FilterTreeEvent event=FilterTreeEvent.class.cast(context.getEventObject());
  List protocols=event.getChildObjects();
  ArrayList result=new ArrayList();
  if (protocols != null && protocols.size() > 0) {
    for (int i=0; i < protocols.size(); i++) {
      String protocol=(String)protocols.get(i);
      if (!(protocol.equals(ServerTags.PORT_UNIF_PROTOCOL_NAME) || protocol.equals(ServerTags.REDIRECT_PROTOCOL_NAME))) {
        result.add(protocol);
      }
    }
  }
  return result;
}
Program: 28288
Project: 28288
Buggy source:
private static String formatActiveIdsForDisplay(String str){
  StringBuilder values=new StringBuilder("String_Node_Str");
  String[] strArray=str.split("String_Node_Str");
  if (strArray != null && strArray.length > 0) {
    values.append("String_Node_Str");
    for (    String s : (String[])strArray) {
      if (s.startsWith("String_Node_Str")) {
        String sh=s.replaceFirst("String_Node_Str","String_Node_Str");
        String[] strHeaders=sh.split("String_Node_Str");
        if (strHeaders != null && strHeaders.length > 0) {
          values.append("String_Node_Str");
          for (          String h : (String[])strHeaders) {
            if (!h.isEmpty()) {
              values.append("String_Node_Str").append("String_Node_Str");
            }
          }
          values.append("String_Node_Str");
        }
      }
 else {
        String[] strData=s.split("String_Node_Str");
        if (strData != null && strData.length > 0) {
          values.append("String_Node_Str");
          for (          String d : (String[])strData) {
            if (!d.isEmpty()) {
              values.append("String_Node_Str").append(d).append("String_Node_Str");
            }
          }
          values.append("String_Node_Str");
        }
      }
    }
    values.append("String_Node_Str");
  }
  return values.toString();
}

Fixed version (ground truth):
private static String formatActiveIdsForDisplay(String str){
  if (str == null) {
    return "String_Node_Str";
  }
  StringBuilder values=new StringBuilder("String_Node_Str");
  String[] strArray=str.split("String_Node_Str");
  if (strArray.length > 0) {
    values.append("String_Node_Str");
    for (    String s : (String[])strArray) {
      if (s.startsWith("String_Node_Str")) {
        String sh=s.replaceFirst("String_Node_Str","String_Node_Str");
        String[] strHeaders=sh.split("String_Node_Str");
        if (strHeaders.length > 0) {
          values.append("String_Node_Str");
          for (          String h : (String[])strHeaders) {
            if (!h.isEmpty()) {
              values.append("String_Node_Str").append("String_Node_Str");
            }
          }
          values.append("String_Node_Str");
        }
      }
 else {
        String[] strData=s.split("String_Node_Str");
        if (strData.length > 0) {
          values.append("String_Node_Str");
          for (          String d : (String[])strData) {
            if (!d.isEmpty()) {
              values.append("String_Node_Str").append(d).append("String_Node_Str");
            }
          }
          values.append("String_Node_Str");
        }
      }
    }
    values.append("String_Node_Str");
  }
  return values.toString();
}
Program: 28290
Project: 28290
Buggy source:
/** 
 * Get set of JAR files that is used to locate local commands (CLICommand). Results can contain JAR files or directories where all JAR files are  used. It must return all JARs or directories with acceptable CLICommands excluding admin-cli.jar. Default implementation returns INSTALL_ROOT_PROPERTY/lib/asadmin
 * @return set of JAR files or directories with JAR files
 */
protected Set<File> getExtensions(){
  Set<File> result=new HashSet<File>();
  final File inst=new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY));
  final File ext=new File(new File(inst,"String_Node_Str"),"String_Node_Str");
  if (ext.exists() && ext.isDirectory()) {
    result.add(ext);
  }
 else {
    logger.finer(strings.get("String_Node_Str",ext));
  }
  result.add(new File(new File(inst,"String_Node_Str"),"String_Node_Str"));
  return result;
}

Fixed version (ground truth):
/** 
 * Get set of JAR files that is used to locate local commands (CLICommand). Results can contain JAR files or directories where all JAR files are  used. It must return all JARs or directories with acceptable CLICommands excluding admin-cli.jar. Default implementation returns INSTALL_ROOT_PROPERTY/lib/asadmin
 * @return set of JAR files or directories with JAR files
 */
protected Set<File> getExtensions(){
  Set<File> result=new HashSet<File>();
  final File inst=new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY));
  final File ext=new File(new File(inst,"String_Node_Str"),"String_Node_Str");
  if (ext.exists() && ext.isDirectory()) {
    result.add(ext);
  }
 else {
    if (logger.isLoggable(Level.FINER))     logger.finer(strings.get("String_Node_Str",ext));
  }
  result.add(new File(new File(inst,"String_Node_Str"),"String_Node_Str"));
  return result;
}
Program: 28291
Project: 28291
Buggy source:
/** 
 * Prints the exception message with level as FINER.
 * @param e the exception object to print
 */
protected void printExceptionStackTrace(java.lang.Throwable e){
  if (!logger.isLoggable(Level.FINER))   return;
  final ByteArrayOutputStream output=new ByteArrayOutputStream(512);
  e.printStackTrace(new java.io.PrintStream(output));
  try {
    output.close();
  }
 catch (  IOException ex) {
  }
  logger.finer(output.toString());
}

Fixed version (ground truth):
/** 
 * Prints the exception message with level as FINER.
 * @param e the exception object to print
 */
protected void printExceptionStackTrace(java.lang.Throwable e){
  if (logger.isLoggable(Level.FINER)) {
    final ByteArrayOutputStream output=new ByteArrayOutputStream(512);
    e.printStackTrace(new java.io.PrintStream(output));
    try {
      output.close();
    }
 catch (    IOException ex) {
    }
    logger.finer(output.toString());
  }
}
Program: 28292
Project: 28292
Buggy source:
/** 
 * The parse method sets the options and operands fields based on the content of the command line arguments. If the program options say this is a help request, we set options and operands as if "--help" had been specified.
 * @throws CommandException if execution of the command fails
 * @throws CommandValidationException if there's something wrongwith the options or arguments
 */
protected void parse() throws CommandException {
  if (programOpts.isHelp()) {
    options=new ParameterMap();
    options.set("String_Node_Str","String_Node_Str");
    operands=Collections.emptyList();
  }
 else {
    Parser rcp=new Parser(argv,1,commandModel.getParameters(),commandModel.unknownOptionsAreOperands());
    options=rcp.getOptions();
    operands=rcp.getOperands();
    if (commandModel.unknownOptionsAreOperands() && operands.size() > 0 && operands.get(0).equals("String_Node_Str"))     operands.remove(0);
  }
  logger.finer("String_Node_Str" + options);
  logger.finer("String_Node_Str" + operands);
}

Fixed version (ground truth):
/** 
 * The parse method sets the options and operands fields based on the content of the command line arguments. If the program options say this is a help request, we set options and operands as if "--help" had been specified.
 * @throws CommandException if execution of the command fails
 * @throws CommandValidationException if there's something wrongwith the options or arguments
 */
protected void parse() throws CommandException {
  if (programOpts.isHelp()) {
    options=new ParameterMap();
    options.set("String_Node_Str","String_Node_Str");
    operands=Collections.emptyList();
  }
 else {
    Parser rcp=new Parser(argv,1,commandModel.getParameters(),commandModel.unknownOptionsAreOperands());
    options=rcp.getOptions();
    operands=rcp.getOperands();
    if (commandModel.unknownOptionsAreOperands() && operands.size() > 0 && operands.get(0).equals("String_Node_Str"))     operands.remove(0);
  }
  if (logger.isLoggable(Level.FINER)) {
    logger.finer("String_Node_Str" + options);
    logger.finer("String_Node_Str" + operands);
  }
}
Program: 28293
Project: 28293
Buggy source:
/** 
 * @param password the password to set
 */
public void setPassword(String password,PasswordLocation location){
  logger.finer("String_Node_Str" + (ok(password) ? "String_Node_Str" : "String_Node_Str"));
  this.password=password;
  this.location=location;
}

Fixed version (ground truth):
/** 
 * @param password the password to set
 */
public void setPassword(String password,PasswordLocation location){
  if (logger.isLoggable(Level.FINER))   logger.finer("String_Node_Str" + (ok(password) ? "String_Node_Str" : "String_Node_Str"));
  this.password=password;
  this.location=location;
}
Program: 28294
Project: 28294
Buggy source:
/** 
 * @param user the user to set
 */
public void setUser(String user){
  logger.finer("String_Node_Str" + user);
  options.set(USER,user);
}

Fixed version (ground truth):
/** 
 * @param user the user to set
 */
public void setUser(String user){
  if (logger.isLoggable(Level.FINER))   logger.finer("String_Node_Str" + user);
  options.set(USER,user);
}
Program: 28295
Project: 28295
Buggy source:
/** 
 * See if DAS is alive, but insist that athentication is correct. Do not print out the results of the version command from the server.
 * @return Error code indicating status
 */
public static Error pingDASWithAuth(ProgramOptions programOpts,Environment env) throws CommandException {
  try {
    RemoteCLICommand cmd=new RemoteCLICommand("String_Node_Str",programOpts,env);
    cmd.executeAndReturnOutput(new String[]{"String_Node_Str"});
  }
 catch (  AuthenticationException aex) {
    return Error.AUTHENTICATION;
  }
catch (  Exception ex) {
    ExceptionAnalyzer ea=new ExceptionAnalyzer(ex);
    if (ea.getFirstInstanceOf(ConnectException.class) != null) {
      logger.finer("String_Node_Str");
      return Error.CONNECTION;
    }
 else     if (ea.getFirstInstanceOf(IOException.class) != null) {
      logger.finer("String_Node_Str" + "String_Node_Str" + ex.getMessage());
      return Error.IO;
    }
 else {
      return Error.UNKNOWN;
    }
  }
  return Error.NONE;
}

Fixed version (ground truth):
/** 
 * See if DAS is alive, but insist that athentication is correct. Do not print out the results of the version command from the server.
 * @return Error code indicating status
 */
public static Error pingDASWithAuth(ProgramOptions programOpts,Environment env) throws CommandException {
  try {
    RemoteCLICommand cmd=new RemoteCLICommand("String_Node_Str",programOpts,env);
    cmd.executeAndReturnOutput(new String[]{"String_Node_Str"});
  }
 catch (  AuthenticationException aex) {
    return Error.AUTHENTICATION;
  }
catch (  Exception ex) {
    ExceptionAnalyzer ea=new ExceptionAnalyzer(ex);
    if (ea.getFirstInstanceOf(ConnectException.class) != null) {
      logger.finer("String_Node_Str");
      return Error.CONNECTION;
    }
 else     if (ea.getFirstInstanceOf(IOException.class) != null) {
      if (logger.isLoggable(Level.FINER))       logger.finer("String_Node_Str" + "String_Node_Str" + ex.getMessage());
      return Error.IO;
    }
 else {
      return Error.UNKNOWN;
    }
  }
  return Error.NONE;
}
Program: 28296
Project: 28296
Buggy source:
/** 
 * See if DAS is alive. Do not print out the results of the version command from the server.
 * @return true if DAS can be reached and can handle commands,otherwise false.
 */
public static boolean pingDASQuietly(ProgramOptions programOpts,Environment env){
  try {
    RemoteCLICommand cmd=new RemoteCLICommand("String_Node_Str",programOpts,env);
    cmd.executeAndReturnOutput(new String[]{"String_Node_Str"});
    return true;
  }
 catch (  AuthenticationException aex) {
    return true;
  }
catch (  Exception ex) {
    ExceptionAnalyzer ea=new ExceptionAnalyzer(ex);
    if (ea.getFirstInstanceOf(ConnectException.class) != null) {
      logger.finer("String_Node_Str");
      return false;
    }
 else     if (ea.getFirstInstanceOf(IOException.class) != null) {
      logger.finer("String_Node_Str" + "String_Node_Str" + ex.getMessage());
      return true;
    }
 else {
      return false;
    }
  }
}

Fixed version (ground truth):
/** 
 * See if DAS is alive. Do not print out the results of the version command from the server.
 * @return true if DAS can be reached and can handle commands,otherwise false.
 */
public static boolean pingDASQuietly(ProgramOptions programOpts,Environment env){
  try {
    RemoteCLICommand cmd=new RemoteCLICommand("String_Node_Str",programOpts,env);
    cmd.executeAndReturnOutput(new String[]{"String_Node_Str"});
    return true;
  }
 catch (  AuthenticationException aex) {
    return true;
  }
catch (  Exception ex) {
    ExceptionAnalyzer ea=new ExceptionAnalyzer(ex);
    if (ea.getFirstInstanceOf(ConnectException.class) != null) {
      logger.finer("String_Node_Str");
      return false;
    }
 else     if (ea.getFirstInstanceOf(IOException.class) != null) {
      if (logger.isLoggable(Level.FINER))       logger.finer("String_Node_Str" + "String_Node_Str" + ex.getMessage());
      return true;
    }
 else {
      return false;
    }
  }
}
Program: 28298
Project: 28298
Buggy source:
@Override protected void prepare() throws CommandException, CommandValidationException {
  try {
    processProgramOptions();
    initializeAuth();
    initializeRemoteAdminCommand();
    if (responseFormatType != null) {
      rac.setResponseFormatType(responseFormatType);
    }
    if (userOut != null) {
      rac.setUserOut(userOut);
    }
    initializeCookieManager();
    if (programOpts.isHelp()) {
      CommandModelData cm=new CommandModelData(name);
      cm.add(new ParamModelData("String_Node_Str",boolean.class,true,"String_Node_Str","String_Node_Str"));
      this.commandModel=cm;
      rac.setCommandModel(cm);
      return;
    }
    commandModel=rac.getCommandModel();
  }
 catch (  CommandException cex) {
    logger.finer("String_Node_Str" + cex);
    throw cex;
  }
catch (  Exception e) {
    logger.finer("String_Node_Str" + e);
    throw new CommandException(e.getMessage());
  }
}

Fixed version (ground truth):
@Override protected void prepare() throws CommandException, CommandValidationException {
  try {
    processProgramOptions();
    initializeAuth();
    initializeRemoteAdminCommand();
    if (responseFormatType != null) {
      rac.setResponseFormatType(responseFormatType);
    }
    if (userOut != null) {
      rac.setUserOut(userOut);
    }
    initializeCookieManager();
    if (programOpts.isHelp()) {
      CommandModelData cm=new CommandModelData(name);
      cm.add(new ParamModelData("String_Node_Str",boolean.class,true,"String_Node_Str","String_Node_Str"));
      this.commandModel=cm;
      rac.setCommandModel(cm);
      return;
    }
    commandModel=rac.getCommandModel();
  }
 catch (  CommandException cex) {
    if (logger.isLoggable(Level.FINER))     logger.finer("String_Node_Str" + cex);
    throw cex;
  }
catch (  Exception e) {
    if (logger.isLoggable(Level.FINER))     logger.finer("String_Node_Str" + e);
    throw new CommandException(e.getMessage());
  }
}
Program: 28299
Project: 28299
Buggy source:
private void initializeAuth() throws CommandException {
  LoginInfo li=null;
  try {
    LoginInfoStore store=LoginInfoStoreFactory.getDefaultStore();
    li=store.read(programOpts.getHost(),programOpts.getPort());
    if (li == null)     return;
  }
 catch (  StoreException se) {
    logger.finer("String_Node_Str");
    return;
  }
  if (programOpts.getUser() == null) {
    logger.finer("String_Node_Str" + li.getUser());
    programOpts.setUser(li.getUser());
    if (programOpts.getPassword() == null) {
      logger.finer("String_Node_Str");
      programOpts.setPassword(li.getPassword(),ProgramOptions.PasswordLocation.LOGIN_FILE);
    }
  }
 else   if (programOpts.getUser().equals(li.getUser())) {
    if (programOpts.getPassword() == null) {
      logger.finer("String_Node_Str");
      programOpts.setPassword(li.getPassword(),ProgramOptions.PasswordLocation.LOGIN_FILE);
    }
  }
}

Fixed version (ground truth):
private void initializeAuth() throws CommandException {
  LoginInfo li=null;
  try {
    LoginInfoStore store=LoginInfoStoreFactory.getDefaultStore();
    li=store.read(programOpts.getHost(),programOpts.getPort());
    if (li == null)     return;
  }
 catch (  StoreException se) {
    logger.finer("String_Node_Str");
    return;
  }
  if (programOpts.getUser() == null) {
    if (logger.isLoggable(Level.FINER))     logger.finer("String_Node_Str" + li.getUser());
    programOpts.setUser(li.getUser());
    if (programOpts.getPassword() == null) {
      logger.finer("String_Node_Str");
      programOpts.setPassword(li.getPassword(),ProgramOptions.PasswordLocation.LOGIN_FILE);
    }
  }
 else   if (programOpts.getUser().equals(li.getUser())) {
    if (programOpts.getPassword() == null) {
      logger.finer("String_Node_Str");
      programOpts.setPassword(li.getPassword(),ProgramOptions.PasswordLocation.LOGIN_FILE);
    }
  }
}
Program: 28300
Project: 28300
Buggy source:
private void addCookieHeaders(final URLConnection urlConnection){
  long modifiedTime=sessionCache.lastModified();
  if (modifiedTime == 0) {
    return;
  }
  ((CookieManager)CookieHandler.getDefault()).getCookieStore().removeAll();
  cookieManager=new CookieManager(new ClientCookieStore(new CookieManager().getCookieStore(),sessionCache),CookiePolicy.ACCEPT_ALL);
  try {
    ((ClientCookieStore)cookieManager.getCookieStore()).load();
  }
 catch (  IOException e) {
    logger.log(Level.FINER,"String_Node_Str",e.toString());
    return;
  }
  if (isSessionCookieExpired(cookieManager,modifiedTime)) {
    logger.finer("String_Node_Str");
    if (!sessionCache.delete()) {
      logger.finer("String_Node_Str");
    }
    return;
  }
  StringBuilder sb=new StringBuilder("String_Node_Str");
  boolean hasCookies=false;
  for (  HttpCookie cookie : cookieManager.getCookieStore().getCookies()) {
    hasCookies=true;
    sb.append("String_Node_Str").append(cookie.getName()).append("String_Node_Str").append(cookie.getValue());
  }
  if (hasCookies) {
    urlConnection.setRequestProperty(COOKIE_HEADER,sb.toString());
  }
}

Fixed version (ground truth):
private void addCookieHeaders(final URLConnection urlConnection){
  long modifiedTime=sessionCache.lastModified();
  if (modifiedTime == 0) {
    return;
  }
  ((CookieManager)CookieHandler.getDefault()).getCookieStore().removeAll();
  cookieManager=new CookieManager(new ClientCookieStore(new CookieManager().getCookieStore(),sessionCache),CookiePolicy.ACCEPT_ALL);
  try {
    ((ClientCookieStore)cookieManager.getCookieStore()).load();
  }
 catch (  IOException e) {
    if (logger.isLoggable(Level.FINER))     logger.finer("String_Node_Str" + e.toString());
    return;
  }
  if (isSessionCookieExpired(cookieManager,modifiedTime)) {
    logger.finer("String_Node_Str");
    if (!sessionCache.delete()) {
      logger.finer("String_Node_Str");
    }
    return;
  }
  StringBuilder sb=new StringBuilder("String_Node_Str");
  boolean hasCookies=false;
  for (  HttpCookie cookie : cookieManager.getCookieStore().getCookies()) {
    hasCookies=true;
    sb.append("String_Node_Str").append(cookie.getName()).append("String_Node_Str").append(cookie.getValue());
  }
  if (hasCookies) {
    urlConnection.setRequestProperty(COOKIE_HEADER,sb.toString());
  }
}
Program: 28301
Project: 28301
Buggy source:
private String[] getListenerNamesForVS(String vsid,List<Map<String,String>> vsAttributes){
  String listeners=null;
  String[] listenerArray=null;
  for (  Map<String,String> atts : vsAttributes) {
    String id=atts.get("String_Node_Str");
    if (id != null && id.equals(vsid)) {
      listeners=atts.get("String_Node_Str");
      if (listeners == null) {
        listeners=atts.get("String_Node_Str");
      }
      break;
    }
  }
  if (GFLauncherUtils.ok(listeners)) {
    listenerArray=listeners.split("String_Node_Str");
    if (listenerArray != null && listenerArray.length <= 0) {
      listenerArray=null;
    }
  }
  if (listenerArray == null) {
    listenerArray=new String[0];
  }
  return listenerArray;
}

Fixed version (ground truth):
/** 
 * Get http listener names for virtual server. Returns null or empty array if not found.
 */
private String[] getListenerNamesForVS(String vsid,List<Map<String,String>> vsAttributes){
  String listeners=null;
  String[] listenerArray=null;
  for (  Map<String,String> atts : vsAttributes) {
    String id=atts.get("String_Node_Str");
    if (id != null && id.equals(vsid)) {
      listeners=atts.get("String_Node_Str");
      if (listeners == null) {
        listeners=atts.get("String_Node_Str");
      }
      break;
    }
  }
  if (GFLauncherUtils.ok(listeners)) {
    listenerArray=listeners.split("String_Node_Str");
    if (listenerArray.length == 0) {
      listenerArray=null;
    }
  }
  return listenerArray;
}
Program: 28302
Project: 28302
Buggy source:
/** 
 * loggingConfig will return an IOException if there is no logging properties file.
 * @return the log filename if available, otherwise return null
 */
public String getLogFilename(){
  String logFilename=null;
  try {
    Map<String,String> map=loggingConfig.getLoggingProperties();
    String logFileContains="String_Node_Str";
    if (map != null) {
      logFilename=map.get(LoggingPropertyNames.file);
    }
    if (logFilename != null && logFilename.contains(logFileContains)) {
      logFilename=replaceOld(logFilename,logFileContains,this.serverName);
    }
  }
 catch (  Exception e) {
  }
  return logFilename;
}

Fixed version (ground truth):
/** 
 * loggingConfig will return an IOException if there is no logging properties file.
 * @return the log filename if available, otherwise return null
 */
public String getLogFilename(){
  String logFilename=null;
  try {
    Map<String,String> map=loggingConfig.getLoggingProperties();
    String logFileContains="String_Node_Str";
    logFilename=map.get(LoggingPropertyNames.file);
    if (logFilename != null && logFilename.contains(logFileContains)) {
      logFilename=replaceOld(logFilename,logFileContains,this.serverName);
    }
  }
 catch (  Exception e) {
  }
  return logFilename;
}
Program: 28303
Project: 28303
Buggy source:
/** 
 * Painfully thorough error-handling.  Some would say over-engineered but I plan on never looking at this code again!
 * @param host1
 * @param host2
 * @return
 */
static public boolean isEqual(String host1,String host2){
  List<String> host1_ips=new ArrayList<String>();
  List<String> host2_ips=new ArrayList<String>();
  try {
    if (!StringUtils.ok(host1) && !StringUtils.ok(host2))     return true;
    if (!StringUtils.ok(host1) || !StringUtils.ok(host2))     return false;
    InetAddress[] adds1=InetAddress.getAllByName(host1);
    InetAddress[] adds2=InetAddress.getAllByName(host2);
    boolean adds1Empty=false;
    boolean adds2Empty=false;
    if (adds1 == null || adds1.length <= 0)     adds1Empty=true;
    if (adds2 == null || adds2.length <= 0)     adds2Empty=true;
    if (adds1Empty && adds2Empty)     return true;
    if (adds1Empty || adds2Empty)     return false;
    for (    InetAddress ia : adds1)     host1_ips.add(ia.getHostAddress());
    for (    InetAddress ia : adds2)     host2_ips.add(ia.getHostAddress());
    for (    String h1ip : host1_ips)     for (    String h2ip : host2_ips)     if (h1ip.equals(h2ip))     return true;
    return false;
  }
 catch (  UnknownHostException ex) {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Painfully thorough error-handling.  Some would say over-engineered but I plan on never looking at this code again!
 * @param host1
 * @param host2
 * @return
 */
static public boolean isEqual(String host1,String host2){
  List<String> host1_ips=new ArrayList<String>();
  List<String> host2_ips=new ArrayList<String>();
  try {
    if (!StringUtils.ok(host1) && !StringUtils.ok(host2))     return true;
    if (!StringUtils.ok(host1) || !StringUtils.ok(host2))     return false;
    InetAddress[] adds1=InetAddress.getAllByName(host1);
    InetAddress[] adds2=InetAddress.getAllByName(host2);
    boolean adds1Empty=false;
    boolean adds2Empty=false;
    if (adds1.length <= 0)     adds1Empty=true;
    if (adds2.length <= 0)     adds2Empty=true;
    if (adds1Empty && adds2Empty)     return true;
    if (adds1Empty || adds2Empty)     return false;
    for (    InetAddress ia : adds1)     host1_ips.add(ia.getHostAddress());
    for (    InetAddress ia : adds2)     host2_ips.add(ia.getHostAddress());
    for (    String h1ip : host1_ips)     for (    String h2ip : host2_ips)     if (h1ip.equals(h2ip))     return true;
    return false;
  }
 catch (  UnknownHostException ex) {
    return false;
  }
}
Program: 28304
Project: 28304
Buggy source:
public Object next() throws NoSuchElementException {
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  final String result=helpdir + locales[i] + "String_Node_Str"+ commandName+ "String_Node_Str"+ sections[j++];
  if (j == sections.length) {
    i++;
    if (i < locales.length)     j=0;
  }
  logger.finer("String_Node_Str" + result);
  return result;
}

Fixed version (ground truth):
public Object next() throws NoSuchElementException {
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  final String result=helpdir + locales[i] + "String_Node_Str"+ commandName+ "String_Node_Str"+ sections[j++];
  if (j == sections.length) {
    i++;
    if (i < locales.length)     j=0;
  }
  logger.log(Level.FINE,"String_Node_Str",result);
  return result;
}
Program: 28305
Project: 28305
Buggy source:
private static Iterator getPossibleLocations(final String cmdName,final String cmdClass,final Locale locale,final Logger logger){
  return new Iterator(){
    final String[] locales=getLocaleLocations(locale);
    private int i=0;
    private int j=0;
    private String helpdir=getHelpDir(cmdClass);
    private String commandName=cmdName;
    public boolean hasNext(){
      return i < locales.length && j < sections.length;
    }
    public Object next() throws NoSuchElementException {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      final String result=helpdir + locales[i] + "String_Node_Str"+ commandName+ "String_Node_Str"+ sections[j++];
      if (j == sections.length) {
        i++;
        if (i < locales.length)         j=0;
      }
      logger.finer("String_Node_Str" + result);
      return result;
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}

Fixed version (ground truth):
private static Iterator getPossibleLocations(final String cmdName,final String cmdClass,final Locale locale,final Logger logger){
  return new Iterator(){
    final String[] locales=getLocaleLocations(locale);
    private int i=0;
    private int j=0;
    private String helpdir=getHelpDir(cmdClass);
    private String commandName=cmdName;
    public boolean hasNext(){
      return i < locales.length && j < sections.length;
    }
    public Object next() throws NoSuchElementException {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      final String result=helpdir + locales[i] + "String_Node_Str"+ commandName+ "String_Node_Str"+ sections[j++];
      if (j == sections.length) {
        i++;
        if (i < locales.length)         j=0;
      }
      logger.log(Level.FINE,"String_Node_Str",result);
      return result;
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
  }
;
}
Program: 28306
Project: 28306
Buggy source:
@Override public ClassLoader getClassLoader(final ClassLoader parent,DeploymentContext context){
  ASURLClassLoader cloader=AccessController.doPrivileged(new PrivilegedAction<ASURLClassLoader>(){
    @Override public ASURLClassLoader run(){
      return new ASURLClassLoader(parent);
    }
  }
);
  try {
    cloader.addURL(context.getSource().getURI().toURL());
    for (    URL url : getManifestLibraries(context)) {
      cloader.addURL(url);
    }
    try {
      final DeploymentContext dc=context;
      final ClassLoader cl=cloader;
      AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.car,dc,cl));
    }
 catch (    PrivilegedActionException e) {
      throw (SecurityException)e.getException();
    }
  }
 catch (  MalformedURLException e) {
    throw new RuntimeException(e);
  }
  return cloader;
}

Fixed version (ground truth):
@Override public ClassLoader getClassLoader(final ClassLoader parent,DeploymentContext context){
  ASURLClassLoader cloader=AccessController.doPrivileged(new PrivilegedAction<ASURLClassLoader>(){
    @Override public ASURLClassLoader run(){
      return new ASURLClassLoader(parent);
    }
  }
);
  try {
    cloader.addURL(context.getSource().getURI().toURL());
    for (    URL url : getManifestLibraries(context)) {
      cloader.addURL(url);
    }
    try {
      final DeploymentContext dc=context;
      final ClassLoader cl=cloader;
      AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.car,dc,cl));
    }
 catch (    PrivilegedActionException e) {
      throw new SecurityException(e.getException());
    }
  }
 catch (  MalformedURLException e) {
    throw new RuntimeException(e);
  }
  return cloader;
}
Program: 28307
Project: 28307
Buggy source:
/** 
 * {@inheritDoc}
 */
public ClassLoader getClassLoader(ClassLoader parent,DeploymentContext context){
  try {
    String moduleDir=context.getSource().getURI().getPath();
    String moduleName=context.getSource().getName();
    List<URI> appLibs=null;
    try {
      appLibs=context.getAppLibs();
      if (_logger.isLoggable(Level.FINEST)) {
        _logger.log(Level.FINEST,"String_Node_Str" + "String_Node_Str" + moduleName + "String_Node_Str"+ appLibs);
      }
    }
 catch (    URISyntaxException e) {
      throw new RuntimeException(e);
    }
    ClassLoader carCL;
    if (isEmbedded(context)) {
      String applicationName=ConnectorsUtil.getApplicationName(context);
      String embeddedRarName=ConnectorsUtil.getEmbeddedRarModuleName(applicationName,moduleName);
      carCL=loader.createRARClassLoader(moduleDir,parent.getParent().getParent(),embeddedRarName,appLibs);
    }
 else {
      carCL=loader.createRARClassLoader(moduleDir,null,moduleName,appLibs);
    }
    try {
      final DeploymentContext dc=context;
      final ClassLoader cl=carCL;
      AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.rar,dc,cl));
    }
 catch (    PrivilegedActionException e) {
      throw (SecurityException)e.getException();
    }
    return carCL;
  }
 catch (  ConnectorRuntimeException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public ClassLoader getClassLoader(ClassLoader parent,DeploymentContext context){
  try {
    String moduleDir=context.getSource().getURI().getPath();
    String moduleName=context.getSource().getName();
    List<URI> appLibs=null;
    try {
      appLibs=context.getAppLibs();
      if (_logger.isLoggable(Level.FINEST)) {
        _logger.log(Level.FINEST,"String_Node_Str" + "String_Node_Str" + moduleName + "String_Node_Str"+ appLibs);
      }
    }
 catch (    URISyntaxException e) {
      throw new RuntimeException(e);
    }
    ClassLoader carCL;
    if (isEmbedded(context)) {
      String applicationName=ConnectorsUtil.getApplicationName(context);
      String embeddedRarName=ConnectorsUtil.getEmbeddedRarModuleName(applicationName,moduleName);
      carCL=loader.createRARClassLoader(moduleDir,parent.getParent().getParent(),embeddedRarName,appLibs);
    }
 else {
      carCL=loader.createRARClassLoader(moduleDir,null,moduleName,appLibs);
    }
    try {
      final DeploymentContext dc=context;
      final ClassLoader cl=carCL;
      AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.rar,dc,cl));
    }
 catch (    PrivilegedActionException e) {
      throw new SecurityException(e.getException());
    }
    return carCL;
  }
 catch (  ConnectorRuntimeException e) {
    throw new RuntimeException(e);
  }
}
Program: 28308
Project: 28308
Buggy source:
@Override public ClassLoader getClassLoader(){
  return parent.getClassLoader();
}

Fixed version (ground truth):
@Override public ClassLoader getClassLoader(){
  if (parent == null)   return null;
  return parent.getClassLoader();
}
Program: 28309
Project: 28309
Buggy source:
private void addEEOrDeclaredPermissions(ClassLoader cloader,final PermissionCollection pc,final boolean isEEPermission){
  if (!(cloader instanceof DDPermissionsLoader))   return;
  final DDPermissionsLoader ddpl=(DDPermissionsLoader)cloader;
  try {
    AccessController.doPrivileged(new PrivilegedExceptionAction(){
      public Object run() throws SecurityException {
        if (isEEPermission)         ddpl.addEEPermissions(pc);
 else         ddpl.addDeclaredPermissions(pc);
        return null;
      }
    }
);
  }
 catch (  PrivilegedActionException e) {
    throw (SecurityException)e.getException();
  }
}

Fixed version (ground truth):
private void addEEOrDeclaredPermissions(ClassLoader cloader,final PermissionCollection pc,final boolean isEEPermission){
  if (!(cloader instanceof DDPermissionsLoader))   return;
  final DDPermissionsLoader ddpl=(DDPermissionsLoader)cloader;
  try {
    AccessController.doPrivileged(new PrivilegedExceptionAction<Object>(){
      public Object run() throws SecurityException {
        if (isEEPermission)         ddpl.addEEPermissions(pc);
 else         ddpl.addDeclaredPermissions(pc);
        return null;
      }
    }
);
  }
 catch (  PrivilegedActionException e) {
    throw new SecurityException(e.getException());
  }
}
Program: 28312
Project: 28312
Buggy source:
/** 
 * If there is a Java SecurityManager create a Permission.
 * @param permission permission to add
 */
public void addPermission(Permission permission){
  if ((securityManager != null) && (permission != null)) {
    if (securityManager != null)     securityManager.checkSecurityAccess(DDPermissionsLoader.SET_EE_POLICY);
    permissionList.add(permission);
  }
}

Fixed version (ground truth):
/** 
 * If there is a Java SecurityManager create a Permission.
 * @param permission permission to add
 */
public void addPermission(Permission permission){
  if ((securityManager != null) && (permission != null)) {
    securityManager.checkSecurityAccess(DDPermissionsLoader.SET_EE_POLICY);
    permissionList.add(permission);
  }
}