Program: 29056
Project: 29056
Buggy source:
/** 
 * Executes the command with the command parameters passed as Properties where the keys are the paramter names and the values the parameter values
 * @param context information
 */
public void execute(AdminCommandContext context){
  final ActionReport report=context.getActionReport();
  if (resourceType == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  if (jndiName == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  if (!(resourceType.equals(TOPIC_CF) || resourceType.equals(QUEUE_CF) || resourceType.equals(UNIFIED_CF)|| resourceType.equals(TOPIC)|| resourceType.equals(QUEUE))) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  jndiNameForConnectionPool=jndiName + JNDINAME_APPENDER;
  if (force) {
    Resource res=null;
    if (resourceType.equals(TOPIC) || resourceType.equals(QUEUE))     res=ConnectorsUtil.getResourceByName(domain.getResources(),AdminObjectResource.class,jndiName);
 else     res=ConnectorsUtil.getResourceByName(domain.getResources(),ConnectorResource.class,jndiName);
    if (res != null) {
      ActionReport deleteReport=report.addSubActionsReport();
      ParameterMap parameters=new ParameterMap();
      parameters.set(DEFAULT_OPERAND,jndiName);
      parameters.set("String_Node_Str",target);
      commandRunner.getCommandInvocation("String_Node_Str",deleteReport).parameters(parameters).execute();
      if (ActionReport.ExitCode.FAILURE.equals(deleteReport.getActionExitCode())) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }
    }
  }
  populateJmsRAMap();
  if (props != null) {
    Enumeration en=props.keys();
    while (en.hasMoreElements()) {
      String key=(String)en.nextElement();
      String raKey=getMappedName(key);
      if (raKey == null)       raKey=key;
      props.put(raKey,(String)props.get(key));
      if (!raKey.equals(key))       props.remove(key);
    }
  }
  ActionReport subReport=report.addSubActionsReport();
  if (resourceType.equals(TOPIC_CF) || resourceType.equals(QUEUE_CF) || resourceType.equals(UNIFIED_CF)) {
    ConnectorConnectionPool cpool=(ConnectorConnectionPool)ConnectorsUtil.getResourceByName(domain.getResources(),ConnectorConnectionPool.class,jndiNameForConnectionPool);
    boolean createdPool=false;
    if (cpool == null || !filterForTarget(jndiNameForConnectionPool)) {
      ParameterMap parameters=populateConnectionPoolParameters();
      commandRunner.getCommandInvocation("String_Node_Str",subReport).parameters(parameters).execute();
      createdPool=true;
      if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
        report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }
    }
    ParameterMap params=populateConnectionResourceParameters();
    commandRunner.getCommandInvocation("String_Node_Str",subReport).parameters(params).execute();
    if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      if (createdPool)       commandRunner.getCommandInvocation("String_Node_Str",subReport).parameters(populateConnectionPoolParameters()).execute();
      return;
    }
  }
 else   if (resourceType.equals(TOPIC) || resourceType.equals(QUEUE)) {
    ParameterMap aoAttrList=new ParameterMap();
    try {
      Properties properties=validateDestinationResourceProps(props,jndiName);
      String propString="String_Node_Str";
      for (      java.util.Map.Entry<Object,Object> prop : properties.entrySet()) {
        propString+=prop.getKey() + "String_Node_Str" + prop.getValue()+ "String_Node_Str";
      }
      propString=propString.substring(0,propString.length());
      aoAttrList.set("String_Node_Str",propString);
    }
 catch (    Exception e) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str" + e.getMessage(),e.getMessage()));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
    aoAttrList.set(DEFAULT_OPERAND,jndiName);
    aoAttrList.set("String_Node_Str",resourceType);
    aoAttrList.set("String_Node_Str",DEFAULT_JMS_ADAPTER);
    aoAttrList.set("String_Node_Str",target);
    if (enabled != null)     aoAttrList.set("String_Node_Str",Boolean.toString(enabled));
    commandRunner.getCommandInvocation("String_Node_Str",subReport).parameters(aoAttrList).execute();
    if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
  }
  ActionReport.ExitCode ec=ActionReport.ExitCode.SUCCESS;
  report.setActionExitCode(ec);
}

Fixed version (ground truth):
/** 
 * Executes the command with the command parameters passed as Properties where the keys are the paramter names and the values the parameter values
 * @param context information
 */
public void execute(AdminCommandContext context){
  final ActionReport report=context.getActionReport();
  if (resourceType == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  if (jndiName == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  if (!(resourceType.equals(TOPIC_CF) || resourceType.equals(QUEUE_CF) || resourceType.equals(UNIFIED_CF)|| resourceType.equals(TOPIC)|| resourceType.equals(QUEUE))) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  jndiNameForConnectionPool=jndiName + JNDINAME_APPENDER;
  if (force) {
    Resource res=null;
    if (resourceType.equals(TOPIC) || resourceType.equals(QUEUE))     res=ConnectorsUtil.getResourceByName(domain.getResources(),AdminObjectResource.class,jndiName);
 else     res=ConnectorsUtil.getResourceByName(domain.getResources(),ConnectorResource.class,jndiName);
    if (res != null) {
      ActionReport deleteReport=report.addSubActionsReport();
      ParameterMap parameters=new ParameterMap();
      parameters.set(DEFAULT_OPERAND,jndiName);
      parameters.set("String_Node_Str",target);
      commandRunner.getCommandInvocation("String_Node_Str",deleteReport).parameters(parameters).execute();
      if (ActionReport.ExitCode.FAILURE.equals(deleteReport.getActionExitCode())) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }
    }
  }
  populateJmsRAMap();
  if (props != null) {
    Enumeration en=props.keys();
    while (en.hasMoreElements()) {
      String key=(String)en.nextElement();
      String raKey=getMappedName(key);
      if (raKey == null)       raKey=key;
      props.put(raKey,(String)props.get(key));
      if (!raKey.equals(key))       props.remove(key);
    }
  }
  ActionReport subReport=report.addSubActionsReport();
  if (resourceType.equals(TOPIC_CF) || resourceType.equals(QUEUE_CF) || resourceType.equals(UNIFIED_CF)) {
    ConnectorConnectionPool cpool=(ConnectorConnectionPool)ConnectorsUtil.getResourceByName(domain.getResources(),ConnectorConnectionPool.class,jndiNameForConnectionPool);
    boolean createdPool=false;
    if (cpool == null || !filterForTarget(jndiNameForConnectionPool)) {
      ParameterMap parameters=populateConnectionPoolParameters();
      commandRunner.getCommandInvocation("String_Node_Str",subReport).parameters(parameters).execute();
      createdPool=true;
      if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
        report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }
    }
    ParameterMap params=populateConnectionResourceParameters();
    commandRunner.getCommandInvocation("String_Node_Str",subReport).parameters(params).execute();
    if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      if (createdPool)       commandRunner.getCommandInvocation("String_Node_Str",subReport).parameters(populateConnectionPoolParameters()).execute();
      return;
    }
  }
 else   if (resourceType.equals(TOPIC) || resourceType.equals(QUEUE)) {
    ParameterMap aoAttrList=new ParameterMap();
    try {
      Properties properties=validateDestinationResourceProps(props,jndiName);
      StringBuilder builder=new StringBuilder();
      for (      java.util.Map.Entry<Object,Object> prop : properties.entrySet()) {
        builder.append(prop.getKey()).append("String_Node_Str").append(prop.getValue()).append("String_Node_Str");
      }
      String propString=builder.toString();
      int lastColonIndex=propString.lastIndexOf("String_Node_Str");
      if (lastColonIndex >= 0) {
        propString=propString.substring(0,lastColonIndex);
      }
      aoAttrList.set("String_Node_Str",propString);
    }
 catch (    Exception e) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str" + e.getMessage(),e.getMessage()));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
    aoAttrList.set(DEFAULT_OPERAND,jndiName);
    aoAttrList.set("String_Node_Str",resourceType);
    aoAttrList.set("String_Node_Str",DEFAULT_JMS_ADAPTER);
    aoAttrList.set("String_Node_Str",target);
    if (enabled != null)     aoAttrList.set("String_Node_Str",Boolean.toString(enabled));
    commandRunner.getCommandInvocation("String_Node_Str",subReport).parameters(aoAttrList).execute();
    if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
  }
  ActionReport.ExitCode ec=ActionReport.ExitCode.SUCCESS;
  report.setActionExitCode(ec);
}