Program: 28788
Project: 28788
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();
  ArrayList<String> list=new ArrayList();
  Properties extraProperties=new Properties();
  Collection adminObjectResourceList=domain.getResources().getResources(AdminObjectResource.class);
  Collection connectorResourcesList=domain.getResources().getResources(ConnectorResource.class);
  Object[] connectorResources=connectorResourcesList.toArray();
  Object[] adminObjectResources=adminObjectResourceList.toArray();
  if (resourceType == null) {
    try {
      for (      Object r : adminObjectResources) {
        AdminObjectResource adminObject=(AdminObjectResource)r;
        if (JMSRA.equalsIgnoreCase(adminObject.getResAdapter()))         list.add(adminObject.getJndiName());
      }
      for (      Object c : connectorResources) {
        ConnectorResource cr=(ConnectorResource)c;
        ConnectorConnectionPool cp=(ConnectorConnectionPool)ConnectorsUtil.getResourceByName(domain.getResources(),ConnectorConnectionPool.class,cr.getPoolName());
        if (cp != null && JMSRA.equalsIgnoreCase(cp.getResourceAdapterName())) {
          list.add(cr.getJndiName());
        }
      }
      if (list.isEmpty()) {
        final ActionReport.MessagePart part=report.getTopMessagePart().addChild();
        part.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
        extraProperties.put("String_Node_Str",list);
      }
 else {
        List<String> resourceList=null;
        if (CommandTarget.DOMAIN.isValid(habitat,target))         resourceList=list;
 else         resourceList=filterListForTarget(list);
        for (        String jndiName : resourceList) {
          final ActionReport.MessagePart part=report.getTopMessagePart().addChild();
          part.setMessage(jndiName);
        }
        extraProperties.put("String_Node_Str",resourceList);
      }
      report.setExtraProperties(extraProperties);
    }
 catch (    Exception e) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str") + "String_Node_Str" + e.getLocalizedMessage());
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      report.setFailureCause(e);
      return;
    }
  }
 else {
    if (resourceType.equals(TOPIC_CF) || resourceType.equals(QUEUE_CF) || resourceType.equals(UNIFIED_CF)) {
      for (      Object c : connectorResources) {
        ConnectorResource cr=(ConnectorResource)c;
        ConnectorConnectionPool cp=(ConnectorConnectionPool)ConnectorsUtil.getResourceByName(domain.getResources(),ConnectorConnectionPool.class,cr.getPoolName());
        if (cp != null && resourceType.equals(cp.getConnectionDefinitionName()) && JMSRA.equalsIgnoreCase(cp.getResourceAdapterName()))         list.add(cp.getName());
      }
    }
 else     if (resourceType.equals(TOPIC) || resourceType.equals(QUEUE)) {
      for (      Object r : adminObjectResources) {
        AdminObjectResource res=(AdminObjectResource)r;
        if (resourceType.equals(res.getResType()))         list.add(res.getJndiName());
      }
    }
    for (    String jndiName : list) {
      final ActionReport.MessagePart part=report.getTopMessagePart().addChild();
      part.setMessage(jndiName);
    }
  }
  report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}

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();
  ArrayList<String> list=new ArrayList();
  Properties extraProperties=new Properties();
  Collection adminObjectResourceList=domain.getResources().getResources(AdminObjectResource.class);
  Collection connectorResourcesList=domain.getResources().getResources(ConnectorResource.class);
  Object[] connectorResources=connectorResourcesList.toArray();
  Object[] adminObjectResources=adminObjectResourceList.toArray();
  if (resourceType == null) {
    try {
      for (      Object r : adminObjectResources) {
        AdminObjectResource adminObject=(AdminObjectResource)r;
        if (JMSRA.equals(adminObject.getResAdapter()))         list.add(adminObject.getJndiName());
      }
      for (      Object c : connectorResources) {
        ConnectorResource cr=(ConnectorResource)c;
        ConnectorConnectionPool cp=(ConnectorConnectionPool)ConnectorsUtil.getResourceByName(domain.getResources(),ConnectorConnectionPool.class,cr.getPoolName());
        if (cp != null && JMSRA.equals(cp.getResourceAdapterName())) {
          list.add(cr.getJndiName());
        }
      }
    }
 catch (    Exception e) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str") + "String_Node_Str" + e.getLocalizedMessage());
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      report.setFailureCause(e);
      return;
    }
  }
 else {
    if (resourceType.equals(TOPIC_CF) || resourceType.equals(QUEUE_CF) || resourceType.equals(UNIFIED_CF)) {
      for (      Object c : connectorResources) {
        ConnectorResource cr=(ConnectorResource)c;
        ConnectorConnectionPool cp=(ConnectorConnectionPool)ConnectorsUtil.getResourceByName(domain.getResources(),ConnectorConnectionPool.class,cr.getPoolName());
        if (cp != null && resourceType.equals(cp.getConnectionDefinitionName()) && JMSRA.equals(cp.getResourceAdapterName()))         list.add(cr.getJndiName());
      }
    }
 else     if (resourceType.equals(TOPIC) || resourceType.equals(QUEUE)) {
      for (      Object r : adminObjectResources) {
        AdminObjectResource res=(AdminObjectResource)r;
        if (resourceType.equals(res.getResType()) && JMSRA.equals(res.getResAdapter()))         list.add(res.getJndiName());
      }
    }
  }
  if (list.isEmpty()) {
    final ActionReport.MessagePart part=report.getTopMessagePart().addChild();
    part.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    extraProperties.put("String_Node_Str",list);
  }
 else {
    List<String> resourceList=null;
    if (CommandTarget.DOMAIN.isValid(habitat,target))     resourceList=list;
 else     resourceList=filterListForTarget(list);
    for (    String jndiName : resourceList) {
      final ActionReport.MessagePart part=report.getTopMessagePart().addChild();
      part.setMessage(jndiName);
    }
    extraProperties.put("String_Node_Str",resourceList);
  }
  report.setExtraProperties(extraProperties);
  report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}