nus-yam/ex-repair huggingface dataset:
Program: 116360
Project: 116360
Buggy source:
@Override public void createApplicationClusters(String appId,ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException {
  if (appClustersContexts == null || appClustersContexts.length == 0) {
    String errorMsg="String_Node_Str";
    LOG.error(errorMsg);
    throw new ApplicationClusterRegistrationException(errorMsg);
  }
  List<Cluster> clusters=new ArrayList<Cluster>();
  for (  ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) {
    dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(),appClusterCtxt.getCartridgeType(),appClusterCtxt.getTextPayload(),appClusterCtxt.getHostName(),appClusterCtxt.isLbCluster(),appClusterCtxt.getProperties()));
    Cluster newCluster=new Cluster(appClusterCtxt.getCartridgeType(),appClusterCtxt.getClusterId(),appClusterCtxt.getDeploymentPolicyName(),appClusterCtxt.getAutoscalePolicyName(),appId);
    newCluster.setLbCluster(false);
    newCluster.setTenantRange(appClusterCtxt.getTenantRange());
    newCluster.setStatus(ClusterStatus.Created);
    newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName()));
    Cartridge cartridge=dataHolder.getCartridge(appClusterCtxt.getCartridgeType());
    if (cartridge.getDeployerType() != null && cartridge.getDeployerType().equals(StratosConstants.KUBERNETES_DEPLOYER_TYPE)) {
      newCluster.setKubernetesCluster(true);
    }
    clusters.add(newCluster);
  }
}

Fixed version (ground truth):
@Override public void createApplicationClusters(String appId,ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException {
  if (appClustersContexts == null || appClustersContexts.length == 0) {
    String errorMsg="String_Node_Str";
    LOG.error(errorMsg);
    throw new ApplicationClusterRegistrationException(errorMsg);
  }
  List<Cluster> clusters=new ArrayList<Cluster>();
  for (  ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) {
    dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(),appClusterCtxt.getCartridgeType(),appClusterCtxt.getTextPayload(),appClusterCtxt.getHostName(),appClusterCtxt.isLbCluster(),appClusterCtxt.getProperties()));
    Cluster newCluster=new Cluster(appClusterCtxt.getCartridgeType(),appClusterCtxt.getClusterId(),appClusterCtxt.getDeploymentPolicyName(),appClusterCtxt.getAutoscalePolicyName(),appId);
    newCluster.setLbCluster(false);
    newCluster.setTenantRange(appClusterCtxt.getTenantRange());
    newCluster.setStatus(ClusterStatus.Created);
    newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName()));
    Cartridge cartridge=dataHolder.getCartridge(appClusterCtxt.getCartridgeType());
    if (cartridge.getDeployerType() != null && cartridge.getDeployerType().equals(StratosConstants.KUBERNETES_DEPLOYER_TYPE)) {
      newCluster.setKubernetesCluster(true);
    }
    clusters.add(newCluster);
  }
  TopologyBuilder.handleApplicationClustersCreated(appId,clusters);
  persist();
}
Program: 116361
Project: 116361
Buggy source:
public static synchronized void handleApplicationCreated(Application application,Set<ApplicationClusterContext> appClusterContexts){
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + application.getUniqueIdentifier());
  }
  ApplicationHolder.acquireWriteLock();
  try {
    Applications applications=ApplicationHolder.getApplications();
    if (applications.getApplication(application.getUniqueIdentifier()) != null) {
      CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(),appClusterContexts);
      ApplicationHolder.persistApplication(application);
      CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(),appClusterContexts);
    }
 else {
      log.warn("String_Node_Str" + application.getUniqueIdentifier() + "String_Node_Str");
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  ApplicationsEventPublisher.sendApplicationCreatedEvent(application);
}

Fixed version (ground truth):
public static synchronized void handleApplicationCreated(Application application,Set<ApplicationClusterContext> appClusterContexts){
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + application.getUniqueIdentifier());
  }
  ApplicationHolder.acquireWriteLock();
  try {
    Applications applications=ApplicationHolder.getApplications();
    if (applications.getApplication(application.getUniqueIdentifier()) == null) {
      CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(),appClusterContexts);
      ApplicationHolder.persistApplication(application);
    }
 else {
      log.warn("String_Node_Str" + application.getUniqueIdentifier() + "String_Node_Str");
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  ApplicationsEventPublisher.sendApplicationCreatedEvent(application);
}
Program: 116363
Project: 116363
Buggy source:
@Override public void createApplicationClusters(String appId,ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException {
  if (appClustersContexts == null || appClustersContexts.length == 0) {
    String errorMsg="String_Node_Str";
    LOG.error(errorMsg);
    throw new ApplicationClusterRegistrationException(errorMsg);
  }
  List<Cluster> clusters=new ArrayList<Cluster>();
  for (  ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) {
    dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(),appClusterCtxt.getCartridgeType(),appClusterCtxt.getTextPayload(),appClusterCtxt.getHostName(),appClusterCtxt.isLbCluster(),appClusterCtxt.getProperties()));
    Cluster newCluster=new Cluster(appClusterCtxt.getCartridgeType(),appClusterCtxt.getClusterId(),appClusterCtxt.getDeploymentPolicyName(),appClusterCtxt.getAutoscalePolicyName(),appId);
    newCluster.setLbCluster(false);
    newCluster.setTenantRange(appClusterCtxt.getTenantRange());
    newCluster.setStatus(ClusterStatus.Created);
    newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName()));
    Cartridge cartridge=dataHolder.getCartridge(appClusterCtxt.getCartridgeType());
    if (cartridge.getDeployerType().equals(StratosConstants.KUBERNETES_DEPLOYER_TYPE)) {
      newCluster.setKubernetesCluster(true);
    }
    clusters.add(newCluster);
  }
}

Fixed version (ground truth):
@Override public void createApplicationClusters(String appId,ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException {
  if (appClustersContexts == null || appClustersContexts.length == 0) {
    String errorMsg="String_Node_Str";
    LOG.error(errorMsg);
    throw new ApplicationClusterRegistrationException(errorMsg);
  }
  List<Cluster> clusters=new ArrayList<Cluster>();
  for (  ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) {
    dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(),appClusterCtxt.getCartridgeType(),appClusterCtxt.getTextPayload(),appClusterCtxt.getHostName(),appClusterCtxt.isLbCluster(),appClusterCtxt.getProperties()));
    Cluster newCluster=new Cluster(appClusterCtxt.getCartridgeType(),appClusterCtxt.getClusterId(),appClusterCtxt.getDeploymentPolicyName(),appClusterCtxt.getAutoscalePolicyName(),appId);
    newCluster.setLbCluster(false);
    newCluster.setTenantRange(appClusterCtxt.getTenantRange());
    newCluster.setStatus(ClusterStatus.Created);
    newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName()));
    Cartridge cartridge=dataHolder.getCartridge(appClusterCtxt.getCartridgeType());
    if (cartridge.getDeployerType() != null && cartridge.getDeployerType().equals(StratosConstants.KUBERNETES_DEPLOYER_TYPE)) {
      newCluster.setKubernetesCluster(true);
    }
    clusters.add(newCluster);
  }
}
Program: 116364
Project: 116364
Buggy source:
public synchronized void createApplicationClusters(String appId,Set<ApplicationClusterContext> appClusterContexts){
}

Fixed version (ground truth):
public synchronized void createApplicationClusters(String appId,Set<ApplicationClusterContext> appClusterContexts){
  List<ApplicationClusterContextDTO> contextDTOs=new ArrayList<ApplicationClusterContextDTO>();
  for (  ApplicationClusterContext context : appClusterContexts) {
    ApplicationClusterContextDTO dto=new ApplicationClusterContextDTO();
    dto.setClusterId(context.getClusterId());
    dto.setAutoscalePolicyName(context.getAutoscalePolicyName());
    dto.setDeploymentPolicyName(context.getDeploymentPolicyName());
    dto.setCartridgeType(context.getCartridgeType());
    dto.setHostName(context.getHostName());
    dto.setTenantRange(context.getTenantRange());
    dto.setTextPayload(context.getTextPayload());
    dto.setLbCluster(context.isLbCluster());
    contextDTOs.add(dto);
  }
  ApplicationClusterContextDTO[] applicationClusterContextDTOs=new ApplicationClusterContextDTO[contextDTOs.size()];
  contextDTOs.toArray(applicationClusterContextDTOs);
  try {
    stub.createApplicationClusters(appId,applicationClusterContextDTOs);
  }
 catch (  RemoteException e) {
    String msg=e.getMessage();
    log.error(msg,e);
  }
catch (  CloudControllerServiceApplicationClusterRegistrationExceptionException e) {
    String msg=e.getMessage();
    log.error(msg,e);
  }
}
Program: 116365
Project: 116365
Buggy source:
@Override public boolean registerService(Registrant registrant) throws UnregisteredCartridgeException {
  String cartridgeType=registrant.getCartridgeType();
  handleNullObject(cartridgeType,"String_Node_Str");
  String clusterId=registrant.getClusterId();
  handleNullObject(clusterId,"String_Node_Str");
  String payload=registrant.getPayload();
  handleNullObject(payload,"String_Node_Str");
  String hostName=registrant.getHostName();
  handleNullObject(hostName,"String_Node_Str");
  Cartridge cartridge=null;
  if ((cartridge=dataHolder.getCartridge(cartridgeType)) == null) {
    String msg="String_Node_Str" + clusterId + "String_Node_Str"+ cartridgeType;
    LOG.error(msg);
    throw new UnregisteredCartridgeException(msg);
  }
  Properties props=CloudControllerUtil.toJavaUtilProperties(registrant.getProperties());
  String property=props.getProperty(Constants.IS_LOAD_BALANCER);
  boolean isLb=property != null ? Boolean.parseBoolean(property) : false;
  ClusterContext ctxt=null;
  dataHolder.addClusterContext(ctxt);
  TopologyBuilder.handleClusterCreated(registrant,isLb);
  persist();
  LOG.info("String_Node_Str" + registrant);
  return true;
}

Fixed version (ground truth):
@Override public boolean registerService(Registrant registrant) throws UnregisteredCartridgeException {
  String cartridgeType=registrant.getCartridgeType();
  handleNullObject(cartridgeType,"String_Node_Str");
  String clusterId=registrant.getClusterId();
  handleNullObject(clusterId,"String_Node_Str");
  String payload=registrant.getPayload();
  handleNullObject(payload,"String_Node_Str");
  String hostName=registrant.getHostName();
  handleNullObject(hostName,"String_Node_Str");
  Cartridge cartridge=null;
  if ((cartridge=dataHolder.getCartridge(cartridgeType)) == null) {
    String msg="String_Node_Str" + clusterId + "String_Node_Str"+ cartridgeType;
    LOG.error(msg);
    throw new UnregisteredCartridgeException(msg);
  }
  Properties props=CloudControllerUtil.toJavaUtilProperties(registrant.getProperties());
  String property=props.getProperty(Constants.IS_LOAD_BALANCER);
  boolean isLb=property != null ? Boolean.parseBoolean(property) : false;
  TopologyBuilder.handleClusterCreated(registrant,isLb);
  persist();
  LOG.info("String_Node_Str" + registrant);
  return true;
}
Program: 116366
Project: 116366
Buggy source:
public void createApplicationClusters(String appId,ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException {
  if (appClustersContexts == null || appClustersContexts.length == 0) {
    String errorMsg="String_Node_Str";
    LOG.error(errorMsg);
    throw new ApplicationClusterRegistrationException(errorMsg);
  }
  List<Cluster> clusters=new ArrayList<Cluster>();
  for (  ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) {
    Cluster newCluster=new Cluster(appClusterCtxt.getCartridgeType(),appClusterCtxt.getClusterId(),appClusterCtxt.getDeploymentPolicyName(),appClusterCtxt.getAutoscalePolicyName(),appId);
    newCluster.setLbCluster(false);
    newCluster.setTenantRange("String_Node_Str");
    newCluster.setStatus(ClusterStatus.Created);
    newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName()));
    clusters.add(newCluster);
  }
  TopologyBuilder.handleApplicationClustersCreated(appId,clusters);
  persist();
}

Fixed version (ground truth):
@Override public void createApplicationClusters(String appId,ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException {
  if (appClustersContexts == null || appClustersContexts.length == 0) {
    String errorMsg="String_Node_Str";
    LOG.error(errorMsg);
    throw new ApplicationClusterRegistrationException(errorMsg);
  }
  List<Cluster> clusters=new ArrayList<Cluster>();
  for (  ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) {
    dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(),appClusterCtxt.getCartridgeType(),appClusterCtxt.getTextPayload(),appClusterCtxt.getHostName(),appClusterCtxt.isLbCluster(),appClusterCtxt.getProperties()));
    Cluster newCluster=new Cluster(appClusterCtxt.getCartridgeType(),appClusterCtxt.getClusterId(),appClusterCtxt.getDeploymentPolicyName(),appClusterCtxt.getAutoscalePolicyName(),appId);
    newCluster.setLbCluster(false);
    newCluster.setTenantRange(appClusterCtxt.getTenantRange());
    newCluster.setStatus(ClusterStatus.Created);
    newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName()));
    Cartridge cartridge=dataHolder.getCartridge(appClusterCtxt.getCartridgeType());
    if (cartridge.getDeployerType().equals(StratosConstants.KUBERNETES_DEPLOYER_TYPE)) {
      newCluster.setKubernetesCluster(true);
    }
    clusters.add(newCluster);
  }
}
Program: 116367
Project: 116367
Buggy source:
private ClusterContext buildClusterContext(Cartridge cartridge,String clusterId,String payload,String hostName,org.apache.stratos.common.Properties props,boolean isLb,Persistence persistence){
  return null;
}

Fixed version (ground truth):
private ClusterContext buildClusterContext(Cartridge cartridge,String clusterId,String payload,String hostName,org.apache.stratos.common.Properties props,boolean isLb,Persistence persistence){
  ClusterContext ctxt=new ClusterContext(clusterId,cartridge.getType(),payload,hostName,isLb,props);
  return null;
}
Program: 116371
Project: 116371
Buggy source:
/** 
 * Parse Group information
 * @param appId Application id
 * @param tenantId tenant id of tenant which deployed the Application
 * @param key Generated key for the Application
 * @param groupCtxts  Group information
 * @param subscribableInformation Subscribable Information
 * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
 * @return Map [alias -> Group]
 * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
 */
private Map<String,Group> parseGroups(String appId,int tenantId,String key,List<GroupContext> groupCtxts,Map<String,SubscribableInfoContext> subscribableInformation,Map<String,GroupContext> definedGroupCtxts,Properties properties) throws ApplicationDefinitionException {
  Map<String,Group> groupAliasToGroup=new HashMap<String,Group>();
  for (  GroupContext groupCtxt : groupCtxts) {
    Group group=parseGroup(appId,tenantId,key,groupCtxt,subscribableInformation,definedGroupCtxts,properties);
    groupAliasToGroup.put(group.getAlias(),group);
  }
  Set<Group> nestedGroups=new HashSet<Group>();
  getNestedGroupContexts(nestedGroups,groupAliasToGroup.values());
  filterDuplicatedGroupContexts(groupAliasToGroup.values(),nestedGroups);
  return groupAliasToGroup;
}

Fixed version (ground truth):
/** 
 * Parse Group information
 * @param appId Application id
 * @param tenantId tenant id of tenant which deployed the Application
 * @param key Generated key for the Application
 * @param groupCtxts  Group information
 * @param subscribableInformation Subscribable Information
 * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
 * @return Map [alias -> Group]
 * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
 */
private Map<String,Group> parseGroups(String appId,int tenantId,String key,List<GroupContext> groupCtxts,Map<String,SubscribableInfoContext> subscribableInformation,Map<String,GroupContext> definedGroupCtxts) throws ApplicationDefinitionException {
  Map<String,Group> groupAliasToGroup=new HashMap<String,Group>();
  for (  GroupContext groupCtxt : groupCtxts) {
    Group group=parseGroup(appId,tenantId,key,groupCtxt,subscribableInformation,definedGroupCtxts);
    groupAliasToGroup.put(group.getAlias(),group);
  }
  Set<Group> nestedGroups=new HashSet<Group>();
  getNestedGroupContexts(nestedGroups,groupAliasToGroup.values());
  filterDuplicatedGroupContexts(groupAliasToGroup.values(),nestedGroups);
  return groupAliasToGroup;
}
Program: 116372
Project: 116372
Buggy source:
/** 
 * Parse Subscription Information
 * @param appId Application id
 * @param tenantId Tenant id of tenant which deployed the Application
 * @param key Generated key for the Application
 * @param groupName Group name (if relevant)
 * @param subscribableCtxts Subscribable Information
 * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
 * @return Map [subscription alias -> ClusterDataHolder]
 * @throws ApplicationDefinitionException
 */
private Map<String,ClusterDataHolder> parseLeafLevelSubscriptions(String appId,int tenantId,String key,String groupName,List<SubscribableContext> subscribableCtxts,Map<String,SubscribableInfoContext> subscribableInfoCtxts,Properties properties) throws ApplicationDefinitionException {
}

Fixed version (ground truth):
/** 
 * Parse Subscription Information
 * @param appId Application id
 * @param tenantId Tenant id of tenant which deployed the Application
 * @param key Generated key for the Application
 * @param groupName Group name (if relevant)
 * @param subscribableCtxts Subscribable Information
 * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
 * @return Map [subscription alias -> ClusterDataHolder]
 * @throws ApplicationDefinitionException
 */
private Map<String,ClusterDataHolder> parseLeafLevelSubscriptions(String appId,int tenantId,String key,String groupName,List<SubscribableContext> subscribableCtxts,Map<String,SubscribableInfoContext> subscribableInfoCtxts) throws ApplicationDefinitionException {
}
Program: 116373
Project: 116373
Buggy source:
/** 
 * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
 * @param appId Application id
 * @param groupName Group name
 * @param cartridgeInfo Cartridge information
 * @param subscriptionKey Generated key for the Application
 * @param tenantId Tenant Id of the tenant which deployed the Application
 * @param repoUrl Repository URL
 * @param alias alias specified for this Subscribable in the Application Definition
 * @param clusterId Cluster id
 * @param hostname Hostname
 * @param deploymentPolicy Deployment policy used
 * @param isLBCluster if this cluster is an LB
 * @param isKubernetesCluster if this cluster is a Kubernetes cluster
 * @return ApplicationClusterContext object with relevant information
 * @throws ApplicationDefinitionException If any error occurs
 */
private ApplicationClusterContext createApplicationClusterContext(String appId,String groupName,CartridgeInfo cartridgeInfo,String subscriptionKey,int tenantId,String repoUrl,String alias,String clusterId,String hostname,String deploymentPolicy,boolean isLBCluster,boolean isKubernetesCluster,String[] dependencyAliases,Properties properties) throws ApplicationDefinitionException {
  String textPayload=ApplicationUtils.createPayload(appId,groupName,cartridgeInfo,subscriptionKey,tenantId,clusterId,hostname,repoUrl,alias,null,dependencyAliases).toString();
  return new ApplicationClusterContext(cartridgeInfo.getType(),clusterId,hostname,textPayload,deploymentPolicy,isLB,isKubernetesCluster,properties);
}

Fixed version (ground truth):
/** 
 * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
 * @param appId Application id
 * @param groupName Group name
 * @param cartridgeInfo Cartridge information
 * @param subscriptionKey Generated key for the Application
 * @param tenantId Tenant Id of the tenant which deployed the Application
 * @param repoUrl Repository URL
 * @param alias alias specified for this Subscribable in the Application Definition
 * @param clusterId Cluster id
 * @param hostname Hostname
 * @param deploymentPolicy Deployment policy used
 * @param isLB if this cluster is an LB
 * @return ApplicationClusterContext object with relevant information
 * @throws ApplicationDefinitionException If any error occurs
 */
private ApplicationClusterContext createApplicationClusterContext(String appId,String groupName,CartridgeInfo cartridgeInfo,String subscriptionKey,int tenantId,String repoUrl,String alias,String clusterId,String hostname,String deploymentPolicy,boolean isLB,String[] dependencyAliases) throws ApplicationDefinitionException {
  String textPayload=ApplicationUtils.createPayload(appId,groupName,cartridgeInfo,subscriptionKey,tenantId,clusterId,hostname,repoUrl,alias,null,dependencyAliases).toString();
  return new ApplicationClusterContext(cartridgeInfo.getType(),clusterId,hostname,textPayload,deploymentPolicy,isLB);
}
Program: 116374
Project: 116374
Buggy source:
protected void activate(ComponentContext context){
}

Fixed version (ground truth):
protected void activate(ComponentContext context){
  try {
    TopicSubscriber subscriber=new TopicSubscriber(CloudControllerConstants.INSTANCE_TOPIC);
    subscriber.setMessageListener(new InstanceStatusEventMessageListener());
    Thread tsubscriber=new Thread(subscriber);
    tsubscriber.start();
    InstanceStatusEventMessageDelegator delegator=new InstanceStatusEventMessageDelegator();
    Thread tdelegator=new Thread(delegator);
    tdelegator.start();
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str");
    }
    clusterStatusTopicReceiver=new ClusterStatusTopicReceiver();
    Thread tClusterStatusTopicReceiver=new Thread(clusterStatusTopicReceiver);
    tClusterStatusTopicReceiver.start();
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str");
    }
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str");
    }
    BundleContext bundleContext=context.getBundleContext();
    bundleContext.registerService(CloudControllerService.class.getName(),new CloudControllerServiceImpl(),null);
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str");
    }
    TopologySynchronizerTaskScheduler.schedule(ServiceReferenceHolder.getInstance().getTaskService());
  }
 catch (  Throwable e) {
    log.error("String_Node_Str",e);
  }
}
Program: 116375
Project: 116375
Buggy source:
public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent clusterActivatedEvent){
  Topology topology=TopologyManager.getTopology();
  Service service=topology.getService(clusterActivatedEvent.getServiceName());
  if (service == null) {
    log.warn(String.format("String_Node_Str",clusterActivatedEvent.getServiceName()));
    return;
  }
  Cluster cluster=service.getCluster(clusterActivatedEvent.getClusterId());
  if (cluster == null) {
    log.warn(String.format("String_Node_Str",clusterActivatedEvent.getClusterId()));
    return;
  }
  org.apache.stratos.messaging.event.topology.ClusterActivatedEvent clusterActivatedEvent1=new org.apache.stratos.messaging.event.topology.ClusterActivatedEvent(clusterActivatedEvent.getAppId(),clusterActivatedEvent.getServiceName(),clusterActivatedEvent.getClusterId());
  try {
    TopologyManager.acquireWriteLock();
    cluster.setStatus(ClusterStatus.Active);
    log.info("String_Node_Str" + cluster.getClusterId());
    TopologyManager.updateTopology(topology);
  }
  finally {
    TopologyManager.releaseWriteLock();
  }
  TopologyEventPublisher.sendClusterActivatedEvent(clusterActivatedEvent1);
}

Fixed version (ground truth):
public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent){
  Topology topology=TopologyManager.getTopology();
  Service service=topology.getService(clusterActivatedEvent.getServiceName());
  if (service == null) {
    log.warn(String.format("String_Node_Str",clusterActivatedEvent.getServiceName()));
    return;
  }
  Cluster cluster=service.getCluster(clusterActivatedEvent.getClusterId());
  if (cluster == null) {
    log.warn(String.format("String_Node_Str",clusterActivatedEvent.getClusterId()));
    return;
  }
  org.apache.stratos.messaging.event.topology.ClusterActivatedEvent clusterActivatedEvent1=new org.apache.stratos.messaging.event.topology.ClusterActivatedEvent(clusterActivatedEvent.getAppId(),clusterActivatedEvent.getServiceName(),clusterActivatedEvent.getClusterId());
  try {
    TopologyManager.acquireWriteLock();
    cluster.setStatus(ClusterStatus.Active);
    log.info("String_Node_Str" + cluster.getClusterId());
    TopologyManager.updateTopology(topology);
  }
  finally {
    TopologyManager.releaseWriteLock();
  }
  TopologyEventPublisher.sendClusterActivatedEvent(clusterActivatedEvent1);
}
Program: 116376
Project: 116376
Buggy source:
protected void activate(ComponentContext context){
}

Fixed version (ground truth):
protected void activate(ComponentContext context){
  try {
    TopicSubscriber subscriber=new TopicSubscriber(CloudControllerConstants.INSTANCE_TOPIC);
    subscriber.setMessageListener(new InstanceStatusEventMessageListener());
    Thread tsubscriber=new Thread(subscriber);
    tsubscriber.start();
    InstanceStatusEventMessageDelegator delegator=new InstanceStatusEventMessageDelegator();
    Thread tdelegator=new Thread(delegator);
    tdelegator.start();
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str");
    }
    clusterStatusTopicReceiver=new ClusterStatusTopicReceiver();
    Thread tClusterStatusTopicReceiver=new Thread(clusterStatusTopicReceiver);
    tClusterStatusTopicReceiver.start();
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str");
    }
    BundleContext bundleContext=context.getBundleContext();
    bundleContext.registerService(CloudControllerService.class.getName(),new CloudControllerServiceImpl(),null);
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str");
    }
    TopologySynchronizerTaskScheduler.schedule(ServiceReferenceHolder.getInstance().getTaskService());
  }
 catch (  Throwable e) {
    log.error("String_Node_Str",e);
  }
}
Program: 116377
Project: 116377
Buggy source:
public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent clusterActivatedEvent){
  Topology topology=TopologyManager.getTopology();
  Service service=topology.getService(clusterActivatedEvent.getServiceName());
  if (service == null) {
    log.warn(String.format("String_Node_Str",clusterActivatedEvent.getServiceName()));
    return;
  }
  Cluster cluster=service.getCluster(clusterActivatedEvent.getClusterId());
  if (cluster == null) {
    log.warn(String.format("String_Node_Str",clusterActivatedEvent.getClusterId()));
    return;
  }
  org.apache.stratos.messaging.event.topology.ClusterActivatedEvent clusterActivatedEvent1=new org.apache.stratos.messaging.event.topology.ClusterActivatedEvent(clusterActivatedEvent.getAppId(),clusterActivatedEvent.getServiceName(),clusterActivatedEvent.getClusterId());
  try {
    TopologyManager.acquireWriteLock();
    cluster.setStatus(ClusterStatus.Active);
    log.info("String_Node_Str" + cluster.getClusterId());
    TopologyManager.updateTopology(topology);
  }
  finally {
    TopologyManager.releaseWriteLock();
  }
  TopologyEventPublisher.sendClusterActivatedEvent(clusterActivatedEvent1);
}

Fixed version (ground truth):
public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent){
  Topology topology=TopologyManager.getTopology();
  Service service=topology.getService(clusterActivatedEvent.getServiceName());
  if (service == null) {
    log.warn(String.format("String_Node_Str",clusterActivatedEvent.getServiceName()));
    return;
  }
  Cluster cluster=service.getCluster(clusterActivatedEvent.getClusterId());
  if (cluster == null) {
    log.warn(String.format("String_Node_Str",clusterActivatedEvent.getClusterId()));
    return;
  }
  org.apache.stratos.messaging.event.topology.ClusterActivatedEvent clusterActivatedEvent1=new org.apache.stratos.messaging.event.topology.ClusterActivatedEvent(clusterActivatedEvent.getAppId(),clusterActivatedEvent.getServiceName(),clusterActivatedEvent.getClusterId());
  try {
    TopologyManager.acquireWriteLock();
    cluster.setStatus(ClusterStatus.Active);
    log.info("String_Node_Str" + cluster.getClusterId());
    TopologyManager.updateTopology(topology);
  }
  finally {
    TopologyManager.releaseWriteLock();
  }
  TopologyEventPublisher.sendClusterActivatedEvent(clusterActivatedEvent1);
}
Program: 116378
Project: 116378
Buggy source:
/** 
 * This will create a new app monitor based on the give appId by getting the application from Topology
 * @param appId appId of the application which requires to create app monitor
 * @return ApplicationMonitor
 * @throws DependencyBuilderException    throws while building dependency for app monitor
 * @throws TopologyInConsistentException throws while traversing thr topology
 */
public static ApplicationMonitor getApplicationMonitor(String appId) throws DependencyBuilderException, TopologyInConsistentException {
  ApplicationMonitor applicationMonitor;
  ApplicationManager.acquireReadLockForApplication(appId);
  try {
    Application application=ApplicationManager.getApplications().getApplication(appId);
    if (application != null) {
      applicationMonitor=new ApplicationMonitor(application);
      applicationMonitor.setHasDependent(false);
    }
 else {
      String msg="String_Node_Str" + appId + "String_Node_Str";
      throw new TopologyInConsistentException(msg);
    }
  }
  finally {
    ApplicationManager.releaseReadLockForApplication(appId);
  }
  return applicationMonitor;
}

Fixed version (ground truth):
/** 
 * This will create a new app monitor based on the give appId by getting the application from Topology
 * @param appId appId of the application which requires to create app monitor
 * @return ApplicationMonitor
 * @throws DependencyBuilderException    throws while building dependency for app monitor
 * @throws TopologyInConsistentException throws while traversing thr topology
 */
public static ApplicationMonitor getApplicationMonitor(String appId) throws DependencyBuilderException, TopologyInConsistentException {
  ApplicationMonitor applicationMonitor;
  ApplicationHolder.acquireReadLock();
  try {
    Application application=ApplicationHolder.getApplications().getApplication(appId);
    if (application != null) {
      applicationMonitor=new ApplicationMonitor(application);
      applicationMonitor.setHasDependent(false);
    }
 else {
      String msg="String_Node_Str" + appId + "String_Node_Str";
      throw new TopologyInConsistentException(msg);
    }
  }
  finally {
    ApplicationHolder.releaseReadLock();
  }
  return applicationMonitor;
}
Program: 116380
Project: 116380
Buggy source:
public String[] getApplicationResourcePaths(){
  Object obj=retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE);
  if (obj != null) {
    if (obj instanceof String[]) {
      return (String[])obj;
    }
 else {
      log.warn("String_Node_Str");
      return null;
    }
  }
  return null;
}

Fixed version (ground truth):
public String[] getApplicationResourcePaths(){
  PrivilegedCarbonContext ctx=PrivilegedCarbonContext.getThreadLocalCarbonContext();
  ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
  ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
  Object obj=retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE);
  if (obj != null) {
    if (obj instanceof String[]) {
      return (String[])obj;
    }
 else {
      log.warn("String_Node_Str");
      return null;
    }
  }
  return null;
}
Program: 116381
Project: 116381
Buggy source:
/** 
 * Persist an object in the local registry.
 * @param dataObj object to be persisted.
 * @param resourcePath resource path to be persisted.
 */
private void persist(Object dataObj,String resourcePath) throws AutoScalerException {
  try {
    registryService.beginTransaction();
    Resource nodeResource=registryService.newResource();
    nodeResource.setContent(Serializer.serializeToByteArray(dataObj));
    registryService.put(resourcePath,nodeResource);
    registryService.commitTransaction();
  }
 catch (  Exception e) {
    try {
      registryService.rollbackTransaction();
    }
 catch (    RegistryException e1) {
      if (log.isErrorEnabled()) {
        log.error("String_Node_Str",e);
      }
    }
    throw new AutoScalerException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Persist an object in the local registry.
 * @param dataObj object to be persisted.
 * @param resourcePath resource path to be persisted.
 */
private void persist(Object dataObj,String resourcePath) throws AutoScalerException {
  PrivilegedCarbonContext ctx=PrivilegedCarbonContext.getThreadLocalCarbonContext();
  ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
  ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
  try {
    registryService.beginTransaction();
    Resource nodeResource=registryService.newResource();
    nodeResource.setContent(Serializer.serializeToByteArray(dataObj));
    registryService.put(resourcePath,nodeResource);
    registryService.commitTransaction();
  }
 catch (  Exception e) {
    try {
      registryService.rollbackTransaction();
    }
 catch (    RegistryException e1) {
      if (log.isErrorEnabled()) {
        log.error("String_Node_Str",e);
      }
    }
    throw new AutoScalerException("String_Node_Str",e);
  }
}
Program: 116382
Project: 116382
Buggy source:
public void persistApplication(Application application){
  String resourcePath=AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + "String_Node_Str"+ application.getUniqueIdentifier();
  persist(application,resourcePath);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + application.getUniqueIdentifier() + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void persistApplication(Application application){
  PrivilegedCarbonContext ctx=PrivilegedCarbonContext.getThreadLocalCarbonContext();
  ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
  ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
  String resourcePath=AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + "String_Node_Str"+ application.getUniqueIdentifier();
  persist(application,resourcePath);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + application.getUniqueIdentifier() + "String_Node_Str");
  }
}
Program: 116383
Project: 116383
Buggy source:
@Override public void init(){
  log.info("String_Node_Str");
}

Fixed version (ground truth):
@Override public void init(){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
}
Program: 116384
Project: 116384
Buggy source:
public static synchronized void handleCompleteApplication(Applications applications){
  log.info("String_Node_Str");
  ApplicationHolder.acquireReadLock();
  try {
    ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications);
  }
  finally {
    ApplicationHolder.releaseReadLock();
  }
}

Fixed version (ground truth):
public static synchronized void handleCompleteApplication(Applications applications){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  ApplicationHolder.acquireReadLock();
  try {
    ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications);
  }
  finally {
    ApplicationHolder.releaseReadLock();
  }
}
Program: 116386
Project: 116386
Buggy source:
private void addEventListeners(){
  statusEventReceiver.addEventListener(new ClusterStatusClusterResetEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterActivatedEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterActivatedEvent((ClusterStatusClusterActivatedEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatedEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterTerminatedEvent((ClusterStatusClusterTerminatedEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatingEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterTerminatingEvent((ClusterStatusClusterTerminatingEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterInactivateEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterInActivateEvent((ClusterStatusClusterInactivateEvent)event);
    }
  }
);
}

Fixed version (ground truth):
private void addEventListeners(){
  statusEventReceiver.addEventListener(new ClusterStatusClusterResetEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterActivatedEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterActivatedEvent((ClusterStatusClusterActivatedEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatedEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterTerminatedEvent((ClusterStatusClusterTerminatedEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatingEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterTerminatingEvent((ClusterStatusClusterTerminatingEvent)event);
    }
  }
);
  statusEventReceiver.addEventListener(new ClusterStatusClusterInactivateEventListener(){
    @Override protected void onEvent(    Event event){
      TopologyBuilder.handleClusterInActivateEvent((ClusterStatusClusterInactivateEvent)event);
    }
  }
);
}
Program: 116387
Project: 116387
Buggy source:
public static void sendClusterCreatedEvent(String appId,String serviceName,String clusterId){
}

Fixed version (ground truth):
public static void sendClusterCreatedEvent(Cluster cluster){
  ClusterCreatedEvent clusterCreatedEvent=new ClusterCreatedEvent(cluster);
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + cluster.getClusterId());
  }
  publishEvent(clusterCreatedEvent);
}
Program: 116388
Project: 116388
Buggy source:
public Cluster(String serviceName,String clusterId,String deploymentPolicyName,String autoscalePolicyName,String appId){
  this.serviceName=serviceName;
  this.clusterId=clusterId;
  this.deploymentPolicyName=deploymentPolicyName;
  this.autoscalePolicyName=autoscalePolicyName;
  this.hostNames=new ArrayList<String>();
  this.memberMap=new HashMap<String,Member>();
  this.appId=appId;
  this.clusterStateManager=new LifeCycleStateManager<ClusterStatus>(ClusterStatus.Created,clusterId);
}

Fixed version (ground truth):
public Cluster(String serviceName,String clusterId,String deploymentPolicyName,String autoscalePolicyName,String appId){
  this.serviceName=serviceName;
  this.clusterId=clusterId;
  this.deploymentPolicyName=deploymentPolicyName;
  this.autoscalePolicyName=autoscalePolicyName;
  this.setHostNames(new ArrayList<String>());
  this.memberMap=new HashMap<String,Member>();
  this.appId=appId;
  this.clusterStateManager=new LifeCycleStateManager<ClusterStatus>(ClusterStatus.Created,clusterId);
}
Program: 116389
Project: 116389
Buggy source:
@Override public void onChildEvent(MonitorStatusEvent statusEvent){
  String id=statusEvent.getId();
  LifeCycleState status1=statusEvent.getStatus();
  if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
    onChildActivatedEvent(id);
  }
 else   if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
    onChildInActiveEvent(id);
  }
 else   if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminated) {
    this.markMonitorAsInactive(id);
  }
 else   if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
    if (this.aliasToInActiveMonitorsMap.containsKey(id)) {
      this.aliasToInActiveMonitorsMap.remove(id);
    }
 else {
      log.warn("String_Node_Str" + id + "String_Node_Str");
    }
    if (this.status != ApplicationStatus.Terminating || this.status != ApplicationStatus.Terminated) {
      onChildTerminatedEvent(id);
    }
 else {
      StatusChecker.getInstance().onChildStatusChange(id,this.id,this.appId);
      log.info("String_Node_Str" + id);
    }
  }
}

Fixed version (ground truth):
@Override public void onChildEvent(MonitorStatusEvent statusEvent){
  String id=statusEvent.getId();
  LifeCycleState status1=statusEvent.getStatus();
  if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
    onChildActivatedEvent(id);
  }
 else   if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
    onChildInActiveEvent(id);
  }
 else   if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
    this.markMonitorAsInactive(id);
  }
 else   if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
    if (this.aliasToInActiveMonitorsMap.containsKey(id)) {
      this.aliasToInActiveMonitorsMap.remove(id);
    }
 else {
      log.warn("String_Node_Str" + id + "String_Node_Str");
    }
    if (this.status == ApplicationStatus.Terminating || this.status == ApplicationStatus.Terminated) {
      StatusChecker.getInstance().onChildStatusChange(id,this.id,this.appId);
      log.info("String_Node_Str" + id);
    }
 else {
      onChildTerminatedEvent(id);
    }
  }
}
Program: 116390
Project: 116390
Buggy source:
@Override public void onChildEvent(MonitorStatusEvent statusEvent){
  String id=statusEvent.getId();
  LifeCycleState status1=statusEvent.getStatus();
  if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
    onChildActivatedEvent(id);
  }
 else   if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
    onChildInActiveEvent(id);
  }
 else   if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminated) {
    this.markMonitorAsInactive(id);
  }
 else   if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
    if (this.aliasToInActiveMonitorsMap.containsKey(id)) {
      this.aliasToInActiveMonitorsMap.remove(id);
    }
 else {
      log.warn("String_Node_Str" + id + "String_Node_Str");
    }
    if (this.status != GroupStatus.Terminating || this.status != GroupStatus.Terminated) {
      onChildTerminatedEvent(id);
    }
 else {
      StatusChecker.getInstance().onChildStatusChange(id,this.id,this.appId);
      log.info("String_Node_Str" + id);
    }
  }
}

Fixed version (ground truth):
@Override public void onChildEvent(MonitorStatusEvent statusEvent){
  String id=statusEvent.getId();
  LifeCycleState status1=statusEvent.getStatus();
  if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
    onChildActivatedEvent(id);
  }
 else   if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
    onChildInActiveEvent(id);
  }
 else   if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
    this.markMonitorAsInactive(id);
  }
 else   if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
    if (this.aliasToInActiveMonitorsMap.containsKey(id)) {
      this.aliasToInActiveMonitorsMap.remove(id);
    }
 else {
      log.warn("String_Node_Str" + id + "String_Node_Str");
    }
    if (this.status == GroupStatus.Terminating || this.status == GroupStatus.Terminated) {
      StatusChecker.getInstance().onChildStatusChange(id,this.id,this.appId);
      log.info("String_Node_Str" + id);
    }
 else {
      onChildTerminatedEvent(id);
    }
  }
}
Program: 116391
Project: 116391
Buggy source:
/** 
 * Executing the commands. Returns a code
 * @param context The context assoicated with the Command Line Application
 * @param args The arguments for the command
 * @param already_parsed_opts Options parsed by any parent parsers.
 * @return The status code
 * @throws org.apache.stratos.cli.exception.CommandException if any errors occur when executing the command
 */
int execute(StratosCommandContext context,String[] args,Option[] already_parsed_opts) throws CommandException ;

Fixed version (ground truth):
/** 
 * Executing the commands. Returns a code
 * @param context The context assoicated with the Command Line Application
 * @param args The arguments for the command
 * @return The status code
 * @throws org.apache.stratos.cli.exception.CommandException if any errors occur when executing the command
 */
int execute(T context,String[] args) throws CommandException ;
Program: 116393
Project: 116393
Buggy source:
@Override protected int executeCommand(String line){
  String[] tokens=new StrTokenizer(line).getTokenArray();
  String action=tokens[0];
  String[] actionArgs=Arrays.copyOfRange(tokens,1,tokens.length);
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str",action,tokens.length);
  }
  Command<StratosCommandContext> command=commands.get(action);
  if (command == null) {
    System.out.println(action + "String_Node_Str");
    return CliConstants.COMMAND_FAILED;
  }
  try {
    return command.execute(context,actionArgs,new Option[0]);
  }
 catch (  CommandException e) {
    if (logger.isErrorEnabled()) {
      logger.error("String_Node_Str" + action,e);
    }
    return CliConstants.ERROR_CODE;
  }
}

Fixed version (ground truth):
@Override protected int executeCommand(String line){
  String[] tokens=new StrTokenizer(line).getTokenArray();
  String action=tokens[0];
  String[] actionArgs=Arrays.copyOfRange(tokens,1,tokens.length);
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str",action,tokens.length);
  }
  Command<StratosCommandContext> command=commands.get(action);
  if (command == null) {
    System.out.println(action + "String_Node_Str");
    return CliConstants.COMMAND_FAILED;
  }
  try {
    return command.execute(context,actionArgs);
  }
 catch (  CommandException e) {
    if (logger.isErrorEnabled()) {
      logger.error("String_Node_Str" + action,e);
    }
    return CliConstants.ERROR_CODE;
  }
}