Program: 28774
Project: 28774
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();
  final String newMB=newMasterBroker;
  Server newMBServer=domain.getServerNamed(newMasterBroker);
  if (newMBServer == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  Cluster cluster=newMBServer.getCluster();
  if (cluster == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  Nodes nodes=domain.getNodes();
  config=domain.getConfigNamed(cluster.getConfigRef());
  JmsService jmsservice=config.getExtensionByType(JmsService.class);
  Server oldMBServer=null;
  if (jmsservice.getMasterBroker() != null) {
    oldMBServer=domain.getServerNamed(jmsservice.getMasterBroker());
  }
 else {
    List<Server> serverList=cluster.getInstances();
    oldMBServer=serverList.get(0);
  }
  String oldMasterBrokerPort=JmsRaUtil.getJMSPropertyValue(oldMBServer);
  if (oldMasterBrokerPort == null) {
    SystemProperty sp=config.getSystemProperty("String_Node_Str");
    if (sp != null)     oldMasterBrokerPort=sp.getValue();
  }
  if (oldMasterBrokerPort == null)   oldMasterBrokerPort=getDefaultJmsHost(jmsservice).getPort();
  String oldMasterBrokerHost=nodes.getNode(oldMBServer.getNodeRef()).getNodeHost();
  String newMasterBrokerPort=JmsRaUtil.getJMSPropertyValue(newMBServer);
  if (newMasterBrokerPort == null)   newMasterBrokerPort=getDefaultJmsHost(jmsservice).getPort();
  String newMasterBrokerHost=nodes.getNode(newMBServer.getNodeRef()).getNodeHost();
  String oldMasterBroker=oldMasterBrokerHost + "String_Node_Str" + oldMasterBrokerPort;
  String newMasterBroker=newMasterBrokerHost + "String_Node_Str" + newMasterBrokerPort;
  try {
    CompositeData result=updateMasterBroker(oldMBServer.getName(),oldMasterBroker,newMasterBroker);
    boolean success=((Boolean)result.get("String_Node_Str")).booleanValue();
    if (!success) {
      int statusCode=((Integer)result.get("String_Node_Str")).intValue();
      String detailMessage=(String)result.get("String_Node_Str");
      String msg="String_Node_Str" + detailMessage;
      if (BrokerStatusCode.BAD_REQUEST.getCode() == statusCode || BrokerStatusCode.NOT_ALLOWED.getCode() == statusCode || BrokerStatusCode.UNAVAILABLE.getCode() == statusCode || BrokerStatusCode.PRECONDITION_FAILED.getCode() == statusCode) {
        msg=msg + "String_Node_Str" + localStrings.getLocalString("String_Node_Str","String_Node_Str");
      }
 else {
        msg=msg + "String_Node_Str" + localStrings.getLocalString("String_Node_Str","String_Node_Str");
      }
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",msg));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
  }
 catch (  Exception e) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  try {
    ConfigSupport.apply(new SingleConfigCode<JmsService>(){
      public Object run(      JmsService param) throws PropertyVetoException, TransactionFailure {
        param.setMasterBroker(newMB);
        return param;
      }
    }
,jmsservice);
  }
 catch (  Exception tfe) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str") + "String_Node_Str" + tfe.getLocalizedMessage());
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    report.setFailureCause(tfe);
  }
  report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",cluster.getName()));
  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();
  final String newMB=newMasterBroker;
  Server newMBServer=domain.getServerNamed(newMasterBroker);
  if (newMBServer == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  Cluster cluster=newMBServer.getCluster();
  if (cluster == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  Nodes nodes=domain.getNodes();
  config=domain.getConfigNamed(cluster.getConfigRef());
  JmsService jmsservice=config.getExtensionByType(JmsService.class);
  Server oldMBServer=null;
  if (jmsservice.getMasterBroker() != null) {
    oldMBServer=domain.getServerNamed(jmsservice.getMasterBroker());
  }
 else {
    List<Server> serverList=cluster.getInstances();
    oldMBServer=serverList.get(0);
  }
  String oldMasterBrokerPort=JmsRaUtil.getJMSPropertyValue(oldMBServer);
  if (oldMasterBrokerPort == null) {
    SystemProperty sp=config.getSystemProperty("String_Node_Str");
    if (sp != null)     oldMasterBrokerPort=sp.getValue();
  }
  if (oldMasterBrokerPort == null)   oldMasterBrokerPort=getDefaultJmsHost(jmsservice).getPort();
  String oldMasterBrokerHost=nodes.getNode(oldMBServer.getNodeRef()).getNodeHost();
  String newMasterBrokerPort=JmsRaUtil.getJMSPropertyValue(newMBServer);
  if (newMasterBrokerPort == null)   newMasterBrokerPort=getDefaultJmsHost(jmsservice).getPort();
  String newMasterBrokerHost=nodes.getNode(newMBServer.getNodeRef()).getNodeHost();
  String oldMasterBroker=oldMasterBrokerHost + "String_Node_Str" + oldMasterBrokerPort;
  String newMasterBroker=newMasterBrokerHost + "String_Node_Str" + newMasterBrokerPort;
  try {
    CompositeData result=updateMasterBroker(oldMBServer.getName(),oldMasterBroker,newMasterBroker);
    boolean success=((Boolean)result.get("String_Node_Str")).booleanValue();
    if (!success) {
      int statusCode=((Integer)result.get("String_Node_Str")).intValue();
      String detailMessage=(String)result.get("String_Node_Str");
      String msg="String_Node_Str" + detailMessage;
      if (BrokerStatusCode.BAD_REQUEST.getCode() == statusCode || BrokerStatusCode.NOT_ALLOWED.getCode() == statusCode || BrokerStatusCode.UNAVAILABLE.getCode() == statusCode || BrokerStatusCode.PRECONDITION_FAILED.getCode() == statusCode) {
        msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",msg);
      }
 else {
        msg=msg + "String_Node_Str" + localStrings.getLocalString("String_Node_Str","String_Node_Str");
      }
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",msg));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
  }
 catch (  Exception e) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str","String_Node_Str"));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  try {
    ConfigSupport.apply(new SingleConfigCode<JmsService>(){
      public Object run(      JmsService param) throws PropertyVetoException, TransactionFailure {
        param.setMasterBroker(newMB);
        return param;
      }
    }
,jmsservice);
  }
 catch (  Exception tfe) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str") + "String_Node_Str" + tfe.getLocalizedMessage());
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    report.setFailureCause(tfe);
  }
  report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",cluster.getName()));
  report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}