nus-yam/ex-repair huggingface dataset:
Program: 116767
Project: 116767
Buggy source:
private static void generateJndiPropertiesFile(){
  String mbIp=System.getProperty("String_Node_Str");
  if (StringUtils.isBlank(mbIp)) {
    throw new RuntimeException("String_Node_Str");
  }
  String mbPort=System.getProperty("String_Node_Str");
  if (StringUtils.isBlank(mbPort)) {
    throw new RuntimeException("String_Node_Str");
  }
  String templateFilePath=System.getProperty("String_Node_Str");
  if (StringUtils.isBlank(templateFilePath)) {
    throw new RuntimeException("String_Node_Str");
  }
  String jndiFileDir=System.getProperty("String_Node_Str");
  if (StringUtils.isBlank(jndiFileDir)) {
    throw new RuntimeException("String_Node_Str");
  }
  String jndiFilePath=null;
  if (jndiFileDir.endsWith("String_Node_Str")) {
    jndiFilePath=jndiFileDir + "String_Node_Str";
  }
 else {
    jndiFilePath=jndiFileDir="String_Node_Str" + "String_Node_Str";
  }
  File templateFile=new File(templateFilePath);
  if (!templateFile.exists()) {
    throw new RuntimeException(String.format("String_Node_Str",templateFilePath));
  }
  try {
    String content=readFileContent(templateFilePath);
    content=content.replace("String_Node_Str",mbIp);
    content=content.replace("String_Node_Str",mbPort);
    writeFileContent(content,jndiFilePath);
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private static void generateJndiPropertiesFile(){
  String mbIp=System.getProperty("String_Node_Str");
  if (StringUtils.isBlank(mbIp)) {
    throw new RuntimeException("String_Node_Str");
  }
  String mbPort=System.getProperty("String_Node_Str");
  if (StringUtils.isBlank(mbPort)) {
    throw new RuntimeException("String_Node_Str");
  }
  String templateFilePath=System.getProperty("String_Node_Str");
  if (StringUtils.isBlank(templateFilePath)) {
    throw new RuntimeException("String_Node_Str");
  }
  String jndiFileDir=System.getProperty("String_Node_Str");
  if (StringUtils.isBlank(jndiFileDir)) {
    throw new RuntimeException("String_Node_Str");
  }
  String jndiFilePath=null;
  if (jndiFileDir.endsWith("String_Node_Str")) {
    jndiFilePath=jndiFileDir + "String_Node_Str";
  }
 else {
    jndiFilePath=jndiFileDir + "String_Node_Str" + "String_Node_Str";
  }
  File templateFile=new File(templateFilePath);
  if (!templateFile.exists()) {
    throw new RuntimeException(String.format("String_Node_Str",templateFilePath));
  }
  try {
    String content=readFileContent(templateFilePath);
    content=content.replace("String_Node_Str",mbIp);
    content=content.replace("String_Node_Str",mbPort);
    writeFileContent(content,jndiFilePath);
    if (log.isDebugEnabled()) {
      log.debug(String.format("String_Node_Str",jndiFilePath));
    }
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}
Program: 116768
Project: 116768
Buggy source:
public static void publishInstanceStartedEvent(){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  InstanceStartedEvent event=new InstanceStartedEvent(CartridgeAgentConfiguration.getInstance().getServiceName(),CartridgeAgentConfiguration.getInstance().getClusterId(),CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(),CartridgeAgentConfiguration.getInstance().getPartitionId(),CartridgeAgentConfiguration.getInstance().getMemberId());
  EventPublisher eventPublisher=new EventPublisher(Constants.INSTANCE_STATUS_TOPIC);
  eventPublisher.publish(event);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
public static void publishInstanceStartedEvent(){
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str");
  }
  InstanceStartedEvent event=new InstanceStartedEvent(CartridgeAgentConfiguration.getInstance().getServiceName(),CartridgeAgentConfiguration.getInstance().getClusterId(),CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(),CartridgeAgentConfiguration.getInstance().getPartitionId(),CartridgeAgentConfiguration.getInstance().getMemberId());
  EventPublisher eventPublisher=new EventPublisher(Constants.INSTANCE_STATUS_TOPIC);
  eventPublisher.publish(event);
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str");
  }
}
Program: 116769
Project: 116769
Buggy source:
public static void publishInstanceActivatedEvent(){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  InstanceActivatedEvent event=new InstanceActivatedEvent(CartridgeAgentConfiguration.getInstance().getServiceName(),CartridgeAgentConfiguration.getInstance().getClusterId(),CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(),CartridgeAgentConfiguration.getInstance().getPartitionId(),CartridgeAgentConfiguration.getInstance().getMemberId());
  EventPublisher eventPublisher=new EventPublisher(Constants.INSTANCE_STATUS_TOPIC);
  eventPublisher.publish(event);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
public static void publishInstanceActivatedEvent(){
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str");
  }
  InstanceActivatedEvent event=new InstanceActivatedEvent(CartridgeAgentConfiguration.getInstance().getServiceName(),CartridgeAgentConfiguration.getInstance().getClusterId(),CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(),CartridgeAgentConfiguration.getInstance().getPartitionId(),CartridgeAgentConfiguration.getInstance().getMemberId());
  EventPublisher eventPublisher=new EventPublisher(Constants.INSTANCE_STATUS_TOPIC);
  eventPublisher.publish(event);
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str");
  }
}
Program: 116772
Project: 116772
Buggy source:
public AutoscalerServiceClient(String epr) throws AxisFault {
  String autosclaerSocketTimeout=(System.getProperty(CartridgeConstants.AUTOSCALER_SOCKET_TIMEOUT) == null) ? "String_Node_Str" : System.getProperty(CartridgeConstants.AUTOSCALER_SOCKET_TIMEOUT);
  String autosclaerConnectionTimeout=(System.getProperty(CartridgeConstants.AUTOSCALER_CONNECTION_TIMEOUT) == null) ? "String_Node_Str" : System.getProperty(CartridgeConstants.AUTOSCALER_CONNECTION_TIMEOUT);
  ConfigurationContext clientConfigContext=DataHolder.getClientConfigContext();
  try {
    stub=new AutoScalerServiceStub(clientConfigContext,epr);
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,autosclaerSocketTimeout);
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,autosclaerConnectionTimeout);
  }
 catch (  AxisFault axisFault) {
    String msg="String_Node_Str" + axisFault.getMessage();
    log.error(msg,axisFault);
    throw new AxisFault(msg,axisFault);
  }
}

Fixed version (ground truth):
public AutoscalerServiceClient(String epr) throws AxisFault {
  String autosclaerSocketTimeout=System.getProperty(CartridgeConstants.AUTOSCALER_SOCKET_TIMEOUT) == null ? "String_Node_Str" : System.getProperty(CartridgeConstants.AUTOSCALER_SOCKET_TIMEOUT);
  String autosclaerConnectionTimeout=System.getProperty(CartridgeConstants.AUTOSCALER_CONNECTION_TIMEOUT) == null ? "String_Node_Str" : System.getProperty(CartridgeConstants.AUTOSCALER_CONNECTION_TIMEOUT);
  ConfigurationContext clientConfigContext=DataHolder.getClientConfigContext();
  try {
    stub=new AutoScalerServiceStub(clientConfigContext,epr);
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,new Integer(autosclaerSocketTimeout));
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,new Integer(autosclaerConnectionTimeout));
  }
 catch (  AxisFault axisFault) {
    String msg="String_Node_Str" + axisFault.getMessage();
    log.error(msg,axisFault);
    throw new AxisFault(msg,axisFault);
  }
}
Program: 116773
Project: 116773
Buggy source:
public CloudControllerServiceClient(String epr) throws AxisFault {
  String ccSocketTimeout=System.getProperty(CartridgeConstants.CC_SOCKET_TIMEOUT) == null ? "String_Node_Str" : System.getProperty(CartridgeConstants.CC_SOCKET_TIMEOUT);
  String ccConnectionTimeout=System.getProperty(CartridgeConstants.CC_CONNECTION_TIMEOUT) == null ? "String_Node_Str" : System.getProperty(CartridgeConstants.CC_CONNECTION_TIMEOUT);
  ConfigurationContext clientConfigContext=DataHolder.getClientConfigContext();
  try {
    stub=new CloudControllerServiceStub(clientConfigContext,epr);
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,ccSocketTimeout);
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,ccConnectionTimeout);
  }
 catch (  AxisFault axisFault) {
    String msg="String_Node_Str" + axisFault.getMessage();
    log.error(msg,axisFault);
    throw new AxisFault(msg,axisFault);
  }
}

Fixed version (ground truth):
public CloudControllerServiceClient(String epr) throws AxisFault {
  String ccSocketTimeout=System.getProperty(CartridgeConstants.CC_SOCKET_TIMEOUT) == null ? "String_Node_Str" : System.getProperty(CartridgeConstants.CC_SOCKET_TIMEOUT);
  String ccConnectionTimeout=System.getProperty(CartridgeConstants.CC_CONNECTION_TIMEOUT) == null ? "String_Node_Str" : System.getProperty(CartridgeConstants.CC_CONNECTION_TIMEOUT);
  ConfigurationContext clientConfigContext=DataHolder.getClientConfigContext();
  try {
    stub=new CloudControllerServiceStub(clientConfigContext,epr);
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,new Integer(ccSocketTimeout));
    stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,new Integer(ccConnectionTimeout));
  }
 catch (  AxisFault axisFault) {
    String msg="String_Node_Str" + axisFault.getMessage();
    log.error(msg,axisFault);
    throw new AxisFault(msg,axisFault);
  }
}
Program: 116774
Project: 116774
Buggy source:
public Service(String type,String autoscalingPolicyName,String deploymentPolicyName,int tenantId,CartridgeInfo cartridgeInfo){
  this.type=type;
  this.autoscalingPolicyName=autoscalingPolicyName;
  this.deploymentPolicyName=deploymentPolicyName;
  this.tenantId=tenantId;
  this.cartridgeInfo=cartridgeInfo;
  this.tenantRange="String_Node_Str";
  this.subscriptionKey=CartridgeSubscriptionUtils.generateSubscriptionKey();
}

Fixed version (ground truth):
public Service(String type,String autoscalingPolicyName,String deploymentPolicyName,int tenantId,CartridgeInfo cartridgeInfo,String tenantRange){
  this.type=type;
  this.autoscalingPolicyName=autoscalingPolicyName;
  this.deploymentPolicyName=deploymentPolicyName;
  this.tenantId=tenantId;
  this.cartridgeInfo=cartridgeInfo;
  this.tenantRange=tenantRange;
  this.subscriptionKey=CartridgeSubscriptionUtils.generateSubscriptionKey();
}
Program: 116776
Project: 116776
Buggy source:
public MultiTenantService(String type,String autoscalingPolicyName,String deploymentPolicyName,int tenantId,CartridgeInfo cartridgeInfo){
  super(type,autoscalingPolicyName,deploymentPolicyName,tenantId,cartridgeInfo);
}

Fixed version (ground truth):
public MultiTenantService(String type,String autoscalingPolicyName,String deploymentPolicyName,int tenantId,CartridgeInfo cartridgeInfo,String tenantRange){
  super(type,autoscalingPolicyName,deploymentPolicyName,tenantId,cartridgeInfo,tenantRange);
}
Program: 116778
Project: 116778
Buggy source:
/** 
 * Super tenant will deploy multitenant service.  get domain , subdomain as well..
 * @param clusterDomain 
 * @param clusterSubdomain 
 */
static void deployService(String cartridgeType,String alias,String autoscalingPolicy,String deploymentPolicy,String tenantDomain,int tenantId,String clusterDomain,String clusterSubdomain,String tenantRange){
  CartridgeSubscription cartridgeSubscription=null;
  try {
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Super tenant will deploy multitenant service.  get domain , subdomain as well..
 * @param clusterDomain 
 * @param clusterSubdomain 
 */
static void deployService(String cartridgeType,String alias,String autoscalingPolicy,String deploymentPolicy,String tenantDomain,int tenantId,String clusterDomain,String clusterSubdomain,String tenantRange){
  log.info("String_Node_Str");
  try {
    serviceDeploymentManager.deployService(cartridgeType,autoscalingPolicy,deploymentPolicy,tenantId,tenantRange);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 116781
Project: 116781
Buggy source:
public BasicPayloadData(){
  payloadBuilder=new StringBuilder();
  createBasicPayloadData();
}

Fixed version (ground truth):
public BasicPayloadData(){
}
Program: 116782
Project: 116782
Buggy source:
public BasicPayloadData(){
  payloadBuilder=new StringBuilder();
}

Fixed version (ground truth):
public BasicPayloadData(){
  payloadBuilder=new StringBuilder();
  createBasicPayloadData();
}
Program: 116783
Project: 116783
Buggy source:
public StringBuilder getPayloadData(){
  payloadBuilder.append("String_Node_Str" + getServiceName());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getHostName());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getMultitenant());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getTenantId());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getTenantRange());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getSubscriptionAlias());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getClusterId());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getSubscriptionKey());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getDeployment());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getApplicationPath());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getGitRepositoryUrl());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + getPortMappings());
  payloadBuilder.append("String_Node_Str");
  payloadBuilder.append("String_Node_Str" + System.getProperty(CartridgeConstants.PUPPET_IP));
  return payloadBuilder;
}

Fixed version (ground truth):
public StringBuilder getPayloadData(){
  return payloadBuilder;
}
Program: 116784
Project: 116784
Buggy source:
public void add(String payloadDataName,String payloadDataValue){
  if (additionalPayloadDataBuilder.length() > 0) {
    additionalPayloadDataBuilder.append("String_Node_Str");
  }
  additionalPayloadDataBuilder.append(payloadDataName + "String_Node_Str" + payloadDataValue);
}

Fixed version (ground truth):
public void add(String payloadDataName,String payloadDataValue){
  if (completePayloadDataBuilder.length() > 0) {
    completePayloadDataBuilder.append("String_Node_Str");
  }
  completePayloadDataBuilder.append(payloadDataName + "String_Node_Str" + payloadDataValue);
}
Program: 116785
Project: 116785
Buggy source:
public PayloadData(BasicPayloadData basicPayloadData){
  this.setBasicPayloadData(basicPayloadData);
  additionalPayloadDataBuilder=new StringBuilder();
}

Fixed version (ground truth):
public PayloadData(BasicPayloadData basicPayloadData){
  this.setBasicPayloadData(basicPayloadData);
  completePayloadDataBuilder=new StringBuilder(basicPayloadData.getPayloadData());
}
Program: 116786
Project: 116786
Buggy source:
public StringBuilder getCompletePayloadData(){
  if (additionalPayloadDataBuilder.length() > 0) {
    return getBasicPayloadData().getPayloadData().append("String_Node_Str").append(additionalPayloadDataBuilder);
  }
 else {
    return getBasicPayloadData().getPayloadData();
  }
}

Fixed version (ground truth):
public StringBuilder getCompletePayloadData(){
  return completePayloadDataBuilder;
}
Program: 116787
Project: 116787
Buggy source:
@Override public boolean validatePartition(Partition partition) throws InvalidPartitionException {
  String provider=partition.getProvider();
  IaasProvider iaasProvider=dataHolder.getIaasProvider(provider);
  if (iaasProvider == null) {
    String msg="String_Node_Str" + partition.toString() + "String_Node_Str"+ provider;
    log.error(msg);
    throw new InvalidPartitionException(msg);
  }
  Iaas iaas=iaasProvider.getIaas();
  if (iaas == null) {
    try {
      iaas=(Iaas)Class.forName(iaasProvider.getClassName()).newInstance();
      ComputeServiceBuilderUtil.buildDefaultComputeService(iaasProvider);
      iaasProvider.setIaas(iaas);
    }
 catch (    Exception e) {
      String msg="String_Node_Str" + iaasProvider.getClassName();
      log.error(msg,e);
      throw new InvalidPartitionException(msg,e);
    }
  }
  PartitionValidator validator=iaas.getPartitionValidator();
  validator.setIaasProvider(iaasProvider);
  validator.validate(partition.getId(),CloudControllerUtil.toJavaUtilProperties(partition.getProperties()));
  return true;
}

Fixed version (ground truth):
@Override public boolean validatePartition(Partition partition) throws InvalidPartitionException {
  String provider=partition.getProvider();
  IaasProvider iaasProvider=dataHolder.getIaasProvider(provider);
  if (iaasProvider == null) {
    String msg="String_Node_Str" + partition.toString() + "String_Node_Str"+ "String_Node_Str"+ provider;
    log.error(msg);
    throw new InvalidPartitionException(msg);
  }
  Iaas iaas=iaasProvider.getIaas();
  if (iaas == null) {
    try {
      iaas=(Iaas)Class.forName(iaasProvider.getClassName()).newInstance();
      ComputeServiceBuilderUtil.buildDefaultComputeService(iaasProvider);
      iaasProvider.setIaas(iaas);
    }
 catch (    Exception e) {
      String msg="String_Node_Str" + iaasProvider.getClassName();
      log.error(msg,e);
      throw new InvalidPartitionException(msg,e);
    }
  }
  PartitionValidator validator=iaas.getPartitionValidator();
  validator.setIaasProvider(iaasProvider);
  validator.validate(partition.getId(),CloudControllerUtil.toJavaUtilProperties(partition.getProperties()));
  return true;
}
Program: 116789
Project: 116789
Buggy source:
private PartitionManager(){
}

Fixed version (ground truth):
private PartitionManager(){
  networkPartitionContexts=new HashMap<String,NetworkPartitionContext>();
}
Program: 116791
Project: 116791
Buggy source:
/** 
 * Handle http post request. Return String
 * @param resourcePath This should be REST endpoint
 * @param jsonParamString The json string which should be executed from the post request
 * @param userName User name for basic auth
 * @param passWord Password for basic auth
 * @return The status of the executed request
 * @throws org.apache.http.client.ClientProtocolException and IOExceptionif any errors occur when executing the request
 */
public String doPost(String resourcePath,String jsonParamString,String userName,String passWord) throws Exception ;

Fixed version (ground truth):
/** 
 * Handle http post request. Return String
 * @param resourcePath This should be REST endpoint
 * @param jsonParamString The json string which should be executed from the post request
 * @param userName User name for basic auth
 * @param passWord Password for basic auth
 * @return The status of the executed request
 * @throws org.apache.http.client.ClientProtocolException and IOExceptionif any errors occur when executing the request
 */
public HttpResponse doPost(String resourcePath,String jsonParamString,String userName,String passWord) throws Exception ;
Program: 116792
Project: 116792
Buggy source:
/** 
 * Handle http get request. Return String
 * @param resourcePath This should be REST endpoint
 * @param userName User name for basic auth
 * @param passWord Password for basic auth
 * @return The status of the executed request
 * @throws org.apache.http.client.ClientProtocolException and IOExceptionif any errors occur when executing the request
 */
public String doGet(String resourcePath,String userName,String passWord);

Fixed version (ground truth):
/** 
 * Handle http get request. Return String
 * @param resourcePath This should be REST endpoint
 * @param userName User name for basic auth
 * @param passWord Password for basic auth
 * @return The status of the executed request
 * @throws org.apache.http.client.ClientProtocolException and IOExceptionif any errors occur when executing the request
 */
public HttpResponse doGet(String resourcePath,String userName,String passWord);
Program: 116794
Project: 116794
Buggy source:
/** 
 * Handle http get request. Return String
 * @param resourcePath This should be REST endpoint
 * @param userName User name for basic auth
 * @param passWord Password for basic auth
 * @return The status of the executed request
 * @throws org.apache.http.client.ClientProtocolException and IOExceptionif any errors occur when executing the request
 */
public String doGet(String resourcePath,String userName,String passWord){
  try {
    DefaultHttpClient httpClient=new DefaultHttpClient();
    HttpGet getRequest=new HttpGet(resourcePath);
    getRequest.addHeader("String_Node_Str","String_Node_Str");
    String userPass=userName + "String_Node_Str" + passWord;
    String basicAuth="String_Node_Str" + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("String_Node_Str"));
    getRequest.addHeader("String_Node_Str",basicAuth);
    httpClient=(DefaultHttpClient)WebClientWrapper.wrapClient(httpClient);
    HttpResponse response=httpClient.execute(getRequest);
    if (response.getStatusLine().getStatusCode() != 200) {
      throw new RuntimeException("String_Node_Str" + response.getStatusLine().getStatusCode());
    }
    BufferedReader br=new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
    String output;
    String result="String_Node_Str";
    while ((output=br.readLine()) != null) {
      result+=output;
    }
    httpClient.getConnectionManager().shutdown();
    return result;
  }
 catch (  ClientProtocolException e) {
    e.printStackTrace();
    return null;
  }
catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Handle http get request. Return String
 * @param resourcePath This should be REST endpoint
 * @param userName User name for basic auth
 * @param passWord Password for basic auth
 * @return The status of the executed request
 * @throws org.apache.http.client.ClientProtocolException and IOExceptionif any errors occur when executing the request
 */
public HttpResponse doGet(String resourcePath,String userName,String passWord){
  try {
    DefaultHttpClient httpClient=new DefaultHttpClient();
    HttpGet getRequest=new HttpGet(resourcePath);
    getRequest.addHeader("String_Node_Str","String_Node_Str");
    String userPass=userName + "String_Node_Str" + passWord;
    String basicAuth="String_Node_Str" + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("String_Node_Str"));
    getRequest.addHeader("String_Node_Str",basicAuth);
    httpClient=(DefaultHttpClient)WebClientWrapper.wrapClient(httpClient);
    HttpResponse response=httpClient.execute(getRequest);
    httpClient.getConnectionManager().shutdown();
    return response;
  }
 catch (  ClientProtocolException e) {
    e.printStackTrace();
    return null;
  }
catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
}
Program: 116795
Project: 116795
Buggy source:
public NetworkPartitionContext getNetworkPartition(String partitionGroupId){
  return networkPartitionContexts.get(partitionGroupId);
}

Fixed version (ground truth):
public NetworkPartitionContext getNetworkPartition(String networkPartitionId){
  return this.networkPartitionContexts.get(networkPartitionId);
}
Program: 116796
Project: 116796
Buggy source:
public void delegateSpawn(PartitionContext partitionContext,String clusterId){
  try {
    String nwPartitionId=partitionContext.getNetworkPartitionId();
    NetworkPartitionContext ctxt=PartitionManager.getInstance().getNetworkPartition(nwPartitionId);
    Properties props=partitionContext.getProperties();
    String value=(String)props.get(org.apache.stratos.messaging.util.Constants.LOAD_BALANCER_REF);
    String lbClusterId;
    if (value.equals(org.apache.stratos.messaging.util.Constants.DEFAULT_LOAD_BALANCER)) {
      lbClusterId=ctxt.getDefaultLbClusterId();
    }
 else     if (value.equals(org.apache.stratos.messaging.util.Constants.SERVICE_AWARE_LOAD_BALANCER)) {
      String serviceName=partitionContext.getServiceName();
      lbClusterId=ctxt.getLBClusterIdOfService(serviceName);
    }
    MemberContext memberContext=CloudControllerClient.getInstance().spawnAnInstance(partitionContext.getPartition(),clusterId,lbClusterId);
    if (memberContext != null) {
      partitionContext.addPendingMember(memberContext);
    }
  }
 catch (  Throwable e) {
    String message="String_Node_Str";
    log.error(message,e);
    throw new RuntimeException(message,e);
  }
}

Fixed version (ground truth):
public void delegateSpawn(PartitionContext partitionContext,String clusterId){
  try {
    String nwPartitionId=partitionContext.getNetworkPartitionId();
    NetworkPartitionContext ctxt=PartitionManager.getInstance().getNetworkPartition(nwPartitionId);
    Properties props=partitionContext.getProperties();
    String value=(String)props.get(org.apache.stratos.messaging.util.Constants.LOAD_BALANCER_REF);
    String lbClusterId=null;
    if (value.equals(org.apache.stratos.messaging.util.Constants.DEFAULT_LOAD_BALANCER)) {
      lbClusterId=ctxt.getDefaultLbClusterId();
    }
 else     if (value.equals(org.apache.stratos.messaging.util.Constants.SERVICE_AWARE_LOAD_BALANCER)) {
      String serviceName=partitionContext.getServiceName();
      lbClusterId=ctxt.getLBClusterIdOfService(serviceName);
    }
    MemberContext memberContext=CloudControllerClient.getInstance().spawnAnInstance(partitionContext.getPartition(),clusterId,lbClusterId);
    if (memberContext != null) {
      partitionContext.addPendingMember(memberContext);
    }
  }
 catch (  Throwable e) {
    String message="String_Node_Str";
    log.error(message,e);
    throw new RuntimeException(message,e);
  }
}
Program: 116797
Project: 116797
Buggy source:
private void doProcessing(Message message){
  String messageType=null;
  try {
    messageType=message.getStringProperty(Constants.EVENT_CLASS_NAME);
  }
 catch (  JMSException e) {
    log.error("String_Node_Str" + message.getClass().toString(),e);
    return;
  }
  log.info("String_Node_Str" + messageType);
  if (ClusterRemovedEvent.class.getName().equals(messageType)) {
    log.info("String_Node_Str" + messageType);
    ClusterRemovedEvent event=getClusterRemovedEvent(message);
    CartridgeSubscriptionInfo cartridgeSubscriptionInfo=getCartridgeSubscriptionInfo(event.getClusterId());
    if (cartridgeSubscriptionInfo != null) {
      Cluster cluster=TopologyManager.getTopology().getService(cartridgeSubscriptionInfo.getCartridge()).getCluster(event.getClusterId());
      TopologyClusterInformationModel.getInstance().addCluster(cartridgeSubscriptionInfo.getTenantId(),cartridgeSubscriptionInfo.getCartridge(),cartridgeSubscriptionInfo.getAlias(),cluster);
    }
  }
}

Fixed version (ground truth):
private void doProcessing(Message message){
  String messageType=null;
  try {
    messageType=message.getStringProperty(Constants.EVENT_CLASS_NAME);
  }
 catch (  JMSException e) {
    log.error("String_Node_Str" + message.getClass().toString(),e);
    return;
  }
  log.info("String_Node_Str" + messageType);
  if (ClusterRemovedEvent.class.getName().equals(messageType)) {
    log.info("String_Node_Str" + messageType);
    ClusterRemovedEvent event=getClusterRemovedEvent(message);
    CartridgeSubscriptionInfo cartridgeSubscriptionInfo=getCartridgeSubscriptionInfo(event.getClusterId());
    if (cartridgeSubscriptionInfo != null) {
      TopologyClusterInformationModel.getInstance().removeCluster(cartridgeSubscriptionInfo.getTenantId(),cartridgeSubscriptionInfo.getCartridge(),cartridgeSubscriptionInfo.getAlias());
    }
  }
}
Program: 116798
Project: 116798
Buggy source:
public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, InvalidIaasProviderException {
  if (cartridgeConfig == null) {
    String msg="String_Node_Str";
    log.error(msg);
    throw new IllegalArgumentException(msg);
  }
  Cartridge cartridge=null;
  try {
    cartridge=CloudControllerUtil.toCartridge(cartridgeConfig);
  }
 catch (  Exception e) {
    String msg="String_Node_Str" + cartridgeConfig.getType();
    log.error(msg,e);
    throw new InvalidCartridgeDefinitionException(msg,e);
  }
  for (  IaasProvider iaasProvider : cartridge.getIaases()) {
    try {
      Iaas iaas=(Iaas)Class.forName(iaasProvider.getClassName()).newInstance();
      iaas.buildComputeServiceAndTemplate(iaasProvider);
      iaasProvider.setIaas(iaas);
    }
 catch (    Exception e) {
      String msg="String_Node_Str" + "String_Node_Str" + iaasProvider.getType();
      log.error(msg,e);
      throw new InvalidIaasProviderException(msg,e);
    }
  }
  dataHolder.addCartridge(cartridge);
  List<Cartridge> cartridgeList=new ArrayList<Cartridge>();
  cartridgeList.add(cartridge);
  TopologyBuilder.handleServiceCreated(cartridgeList);
  log.info("String_Node_Str" + cartridge.getType());
}

Fixed version (ground truth):
public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, InvalidIaasProviderException {
  if (cartridgeConfig == null) {
    String msg="String_Node_Str";
    log.error(msg);
    throw new IllegalArgumentException(msg);
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + cartridgeConfig.toString());
  }
  Cartridge cartridge=null;
  try {
    cartridge=CloudControllerUtil.toCartridge(cartridgeConfig);
  }
 catch (  Exception e) {
    String msg="String_Node_Str" + cartridgeConfig.getType();
    log.error(msg,e);
    throw new InvalidCartridgeDefinitionException(msg,e);
  }
  for (  IaasProvider iaasProvider : cartridge.getIaases()) {
    try {
      Iaas iaas=(Iaas)Class.forName(iaasProvider.getClassName()).newInstance();
      iaas.buildComputeServiceAndTemplate(iaasProvider);
      iaasProvider.setIaas(iaas);
    }
 catch (    Exception e) {
      String msg="String_Node_Str" + "String_Node_Str" + iaasProvider.getType();
      log.error(msg,e);
      throw new InvalidIaasProviderException(msg,e);
    }
  }
  dataHolder.addCartridge(cartridge);
  List<Cartridge> cartridgeList=new ArrayList<Cartridge>();
  cartridgeList.add(cartridge);
  TopologyBuilder.handleServiceCreated(cartridgeList);
  log.info("String_Node_Str" + cartridge.getType());
}
Program: 116799
Project: 116799
Buggy source:
private String getDeploymentDetails(){
  StringBuilder deploymentDetailBuilder=new StringBuilder();
  deploymentDetailBuilder.append("String_Node_Str" + baseDir);
  if (deploymentDirs.length > 0) {
    deploymentDetailBuilder.append("String_Node_Str");
    for (    String directory : deploymentDirs) {
      deploymentDetailBuilder.append(directory + "String_Node_Str");
    }
  }
  return deploymentDetailBuilder.toString();
}

Fixed version (ground truth):
private String getDeploymentDetails(){
  StringBuilder deploymentDetailBuilder=new StringBuilder();
  deploymentDetailBuilder.append("String_Node_Str" + baseDir);
  if (deploymentDirs != null) {
    if (deploymentDirs.length > 0) {
      deploymentDetailBuilder.append("String_Node_Str");
      for (      String directory : deploymentDirs) {
        deploymentDetailBuilder.append(directory + "String_Node_Str");
      }
    }
  }
  return deploymentDetailBuilder.toString();
}
Program: 116800
Project: 116800
Buggy source:
private String getPortMappingDetails(){
  StringBuilder portMappingDetailBuilder=new StringBuilder();
  if (portMappings.length > 0) {
    for (    PortMapping portMapping : portMappings) {
      portMappingDetailBuilder.append(portMapping.toString() + "String_Node_Str");
    }
  }
  return portMappingDetailBuilder.toString();
}

Fixed version (ground truth):
private String getPortMappingDetails(){
  StringBuilder portMappingDetailBuilder=new StringBuilder();
  if (portMappings != null) {
    if (portMappings.length > 0) {
      for (      PortMapping portMapping : portMappings) {
        portMappingDetailBuilder.append(portMapping.toString() + "String_Node_Str");
      }
    }
  }
  return portMappingDetailBuilder.toString();
}
Program: 116801
Project: 116801
Buggy source:
private String getIaasConfigDetails(){
  StringBuilder iaasConfigDetailBuilder=new StringBuilder();
  if (iaasConfigs.length > 0) {
    for (    IaasConfig iaasConfig : iaasConfigs) {
      iaasConfigDetailBuilder.append(iaasConfig.toString() + "String_Node_Str");
    }
  }
  return iaasConfigDetailBuilder.toString();
}

Fixed version (ground truth):
private String getIaasConfigDetails(){
  StringBuilder iaasConfigDetailBuilder=new StringBuilder();
  if (iaasConfigs != null) {
    if (iaasConfigs.length > 0) {
      for (      IaasConfig iaasConfig : iaasConfigs) {
        iaasConfigDetailBuilder.append(iaasConfig.toString() + "String_Node_Str");
      }
    }
  }
  return iaasConfigDetailBuilder.toString();
}
Program: 116802
Project: 116802
Buggy source:
public String toString(){
  return "String_Node_Str" + type + "String_Node_Str"+ imageId+ "String_Node_Str"+ maxInstanceLimit+ "String_Node_Str"+ getIaasProperties()+ "String_Node_Str";
}

Fixed version (ground truth):
public String toString(){
  return "String_Node_Str" + type + "String_Node_Str"+ name+ "String_Node_Str"+ className+ "String_Node_Str"+ imageId+ "String_Node_Str"+ maxInstanceLimit+ "String_Node_Str"+ provider+ "String_Node_Str"+ identity+ "String_Node_Str"+ credential+ "String_Node_Str"+ getIaasProperties()+ "String_Node_Str";
}
Program: 116803
Project: 116803
Buggy source:
public WSO2CEPStatsPublisher(){
  ip=System.getProperty("String_Node_Str");
  port=System.getProperty("String_Node_Str");
  String enabledStr=System.getProperty("String_Node_Str");
  if (StringUtils.isNotBlank(enabledStr)) {
    enabled=Boolean.getBoolean(enabledStr);
  }
  if (enabled) {
    init();
  }
}

Fixed version (ground truth):
public WSO2CEPStatsPublisher(){
  ip=System.getProperty("String_Node_Str");
  port=System.getProperty("String_Node_Str");
  enabled=Boolean.getBoolean("String_Node_Str");
  if (enabled) {
    init();
  }
}
Program: 116804
Project: 116804
Buggy source:
@Override public void publish(Map<String,Integer> stats){
  if (!isEnabled()) {
    throw new RuntimeException("String_Node_Str");
  }
  for (  Map.Entry<String,Integer> entry : stats.entrySet()) {
    Object[] payload=new Object[]{entry.getKey(),entry.getValue()};
    Event event=eventObject(null,null,payload,new HashMap<String,String>());
    try {
      asyncDataPublisher.publish(CALL_CENTER_DATA_STREAM,VERSION,event);
    }
 catch (    AgentException e) {
      log.error("String_Node_Str",e);
    }
  }
  stats=null;
}

Fixed version (ground truth):
@Override public void publish(Map<String,Integer> stats){
  if (!isEnabled()) {
    throw new RuntimeException("String_Node_Str");
  }
  for (  Map.Entry<String,Integer> entry : stats.entrySet()) {
    Object[] payload=new Object[]{entry.getKey(),entry.getValue()};
    Event event=eventObject(null,null,payload,new HashMap<String,String>());
    try {
      if (log.isInfoEnabled()) {
        log.info(String.format("String_Node_Str",CALL_CENTER_DATA_STREAM,VERSION,Arrays.toString(payload)));
      }
      asyncDataPublisher.publish(CALL_CENTER_DATA_STREAM,VERSION,event);
    }
 catch (    AgentException e) {
      log.error("String_Node_Str",e);
    }
  }
  stats=null;
}
Program: 116806
Project: 116806
Buggy source:
public Partition getNextScaleDownPartition(String clusterId){
  String policyId;
  int nextPartitionIndex;
  ClusterContext clusterContext=AutoscalerContext.getInstance().getClusterContext(clusterId);
  int currentPartitionIndex=clusterContext.getCurrentPartitionIndex();
  String serviceId=AutoscalerContext.getInstance().getClusterContext(clusterId).getServiceId();
  policyId=TopologyManager.getTopology().getService(serviceId).getCluster(clusterId).getAutoscalePolicyName();
  int noOfPartitions=PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().size();
  if (currentPartitionIndex - 1 >= noOfPartitions) {
    nextPartitionIndex=0;
  }
 else {
    nextPartitionIndex=currentPartitionIndex--;
  }
  AutoscalerContext.getInstance().getClusterContext(clusterId).setCurrentPartitionIndex(nextPartitionIndex);
  Partition nextPartition=PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().get(nextPartitionIndex);
  String nextPartitionId=nextPartition.getId();
  if (clusterContext.partitionCountExists(nextPartitionId) && (clusterContext.getPartitionCount(nextPartitionId) <= nextPartition.getPartitionMembersMin())) {
    nextPartition=getNextScaleDownPartition(clusterId);
  }
  return nextPartition;
}

Fixed version (ground truth):
public Partition getNextScaleDownPartition(String clusterId){
  String policyId;
  int previousPartitionIndex;
  ClusterContext clusterContext=AutoscalerContext.getInstance().getClusterContext(clusterId);
  int currentPartitionIndex=clusterContext.getCurrentPartitionIndex();
  String serviceId=AutoscalerContext.getInstance().getClusterContext(clusterId).getServiceId();
  policyId=TopologyManager.getTopology().getService(serviceId).getCluster(clusterId).getAutoscalePolicyName();
  int noOfPartitions=PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().size();
  for (int i=0; i < noOfPartitions; i++) {
    if (currentPartitionIndex == 0) {
      previousPartitionIndex=noOfPartitions - 1;
    }
 else {
      previousPartitionIndex=currentPartitionIndex - 1;
    }
    AutoscalerContext.getInstance().getClusterContext(clusterId).setCurrentPartitionIndex(previousPartitionIndex);
    Partition previousPartition=PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().get(previousPartitionIndex);
    String previousPartitionId=previousPartition.getId();
    if (clusterContext.partitionCountExists(previousPartitionId) && (clusterContext.getPartitionCount(previousPartitionId) > previousPartition.getPartitionMembersMin())) {
      return previousPartition;
    }
  }
  return null;
}
Program: 116807
Project: 116807
Buggy source:
public Partition getNextScaleUpPartition(String clusterId){
  String policyId;
  int nextPartitionIndex;
  ClusterContext clusterContext=AutoscalerContext.getInstance().getClusterContext(clusterId);
  int currentPartitionIndex=clusterContext.getCurrentPartitionIndex();
  String serviceId=AutoscalerContext.getInstance().getClusterContext(clusterId).getServiceId();
  policyId=TopologyManager.getTopology().getService(serviceId).getCluster(clusterId).getAutoscalePolicyName();
  int noOfPartitions=PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().size();
  if (currentPartitionIndex + 1 >= noOfPartitions) {
    nextPartitionIndex=0;
  }
 else {
    nextPartitionIndex=currentPartitionIndex++;
  }
  AutoscalerContext.getInstance().getClusterContext(clusterId).setCurrentPartitionIndex(nextPartitionIndex);
  Partition nextPartition=PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().get(nextPartitionIndex);
  String nextPartitionId=nextPartition.getId();
  if (clusterContext.partitionCountExists(nextPartitionId)) {
    if (clusterContext.getPartitionCount(nextPartitionId) >= nextPartition.getPartitionMembersMax()) {
      nextPartition=getNextScaleUpPartition(clusterId);
    }
  }
 else {
    AutoscalerContext.getInstance().getClusterContext(clusterId).addPartitionCount(nextPartitionId,1);
  }
  return nextPartition;
}

Fixed version (ground truth):
public Partition getNextScaleUpPartition(String clusterId){
  ClusterContext clusterContext=AutoscalerContext.getInstance().getClusterContext(clusterId);
  String serviceId=AutoscalerContext.getInstance().getClusterContext(clusterId).getServiceId();
  String policyId=TopologyManager.getTopology().getService(serviceId).getCluster(clusterId).getAutoscalePolicyName();
  int noOfPartitions=PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().size();
  for (int i=0; i < noOfPartitions; i++) {
    int currentPartitionIndex=clusterContext.getCurrentPartitionIndex();
    Partition currentPartition=PolicyManager.getInstance().getPolicy(policyId).getHAPolicy().getPartitions().get(currentPartitionIndex);
    String currentPartitionId=currentPartition.getId();
    currentPartitionIndex=currentPartitionIndex + 1 == noOfPartitions ? 0 : currentPartitionIndex + 1;
    AutoscalerContext.getInstance().getClusterContext(clusterId).setCurrentPartitionIndex(currentPartitionIndex);
    if (clusterContext.getPartitionCount(currentPartitionId) < currentPartition.getPartitionMembersMax()) {
      AutoscalerContext.getInstance().getClusterContext(clusterId).addPartitionCount(currentPartitionId,1);
      return currentPartition;
    }
  }
  return null;
}
Program: 116809
Project: 116809
Buggy source:
public void setPartitionsList(){
  Collection<Partition> partitions=TopologyManager.getInstance().getTopology().getPartitions();
  List<OMNode> nodeList=getMatchingNodes(CloudControllerConstants.PARTITION_XPATH);
  if (nodeList == null || nodeList.isEmpty()) {
    return;
  }
  for (  OMNode node : nodeList) {
    partitions.add(getPartition(node,partitions));
  }
}

Fixed version (ground truth):
public void setPartitionsList(){
  Set<String> partitionIds=TopologyManager.getInstance().getTopology().getPartitionMap().keySet();
  List<String> ids=new ArrayList<String>();
  List<OMNode> nodeList=getMatchingNodes(CloudControllerConstants.PARTITION_XPATH);
  if (nodeList == null || nodeList.isEmpty()) {
    return;
  }
  for (  OMNode node : nodeList) {
    ids.add(getPartition(node).getId());
  }
  boolean isFound;
  for (  String parId : partitionIds) {
    isFound=false;
    for (    String id : ids) {
      if (parId.equals(id)) {
        isFound=true;
        break;
      }
    }
    if (!isFound) {
      TopologyBuilder.handlePartitionRemoved(TopologyManager.getInstance().getTopology().getPartition(parId));
    }
  }
}
Program: 116811
Project: 116811
Buggy source:
public static void handlePartitionCreated(Partition partition){
  Topology topology=TopologyManager.getInstance().getTopology();
  if (partition == null) {
    throw new RuntimeException(String.format("String_Node_Str"));
  }
  try {
    TopologyManager.getInstance().acquireWriteLock();
    topology.addPartition(partition);
  }
  finally {
    TopologyManager.getInstance().releaseWriteLock();
  }
  TopologyEventSender.sendPartitionCreatedEvent(partition);
}

Fixed version (ground truth):
public static void handlePartitionCreated(Partition partition){
  Topology topology=TopologyManager.getInstance().getTopology();
  if (partition == null) {
    throw new RuntimeException(String.format("String_Node_Str"));
  }
  try {
    TopologyManager.getInstance().acquireWriteLock();
    topology.addPartition(partition);
    TopologyManager.getInstance().updateTopology(topology);
  }
  finally {
    TopologyManager.getInstance().releaseWriteLock();
  }
  TopologyEventSender.sendPartitionCreatedEvent(partition);
}
Program: 116812
Project: 116812
Buggy source:
public static void handlePartitionRemoved(Partition partition){
  Topology topology=TopologyManager.getInstance().getTopology();
  if (partition == null) {
    throw new RuntimeException(String.format("String_Node_Str"));
  }
  try {
    TopologyManager.getInstance().acquireWriteLock();
    topology.removePartition(partition);
  }
  finally {
    TopologyManager.getInstance().releaseWriteLock();
  }
  TopologyEventSender.sendPartitionRemovedEvent(partition);
}

Fixed version (ground truth):
public static void handlePartitionRemoved(Partition partition){
  Topology topology=TopologyManager.getInstance().getTopology();
  if (partition == null) {
    throw new RuntimeException(String.format("String_Node_Str"));
  }
  try {
    TopologyManager.getInstance().acquireWriteLock();
    topology.removePartition(partition);
    TopologyManager.getInstance().updateTopology(topology);
  }
  finally {
    TopologyManager.getInstance().releaseWriteLock();
  }
  TopologyEventSender.sendPartitionRemovedEvent(partition);
}
Program: 116813
Project: 116813
Buggy source:
public static void handlePartitionUpdated(Partition newPartition,Partition oldPartition){
  Topology topology=TopologyManager.getInstance().getTopology();
  if (newPartition == null || oldPartition == null) {
    throw new RuntimeException(String.format("String_Node_Str"));
  }
  try {
    TopologyManager.getInstance().acquireWriteLock();
    topology.removePartition(oldPartition);
    topology.addPartition(newPartition);
  }
  finally {
    TopologyManager.getInstance().releaseWriteLock();
  }
  TopologyEventSender.sendPartitionUpdatedEvent(newPartition,oldPartition.getId());
}

Fixed version (ground truth):
public static void handlePartitionUpdated(Partition newPartition,Partition oldPartition){
  Topology topology=TopologyManager.getInstance().getTopology();
  if (newPartition == null || oldPartition == null) {
    throw new RuntimeException(String.format("String_Node_Str"));
  }
  try {
    TopologyManager.getInstance().acquireWriteLock();
    topology.removePartition(oldPartition);
    topology.addPartition(newPartition);
    TopologyManager.getInstance().updateTopology(topology);
  }
  finally {
    TopologyManager.getInstance().releaseWriteLock();
  }
  TopologyEventSender.sendPartitionUpdatedEvent(newPartition,oldPartition.getId());
}
Program: 116814
Project: 116814
Buggy source:
/** 
 * Add the user defined payload String (if any). This should be of the format <key_1>=<value_1>,<key_2>=<value_2>,....<key_n>=<value_n>
 * @param payloadString String object with payload information
 */
public void populatePayload(String payloadString){
  if (payloadBuilder.toString().isEmpty()) {
    if (payloadString.startsWith("String_Node_Str")) {
      payloadBuilder.append(payloadString.substring(1));
    }
  }
 else {
    if (!payloadBuilder.toString().endsWith("String_Node_Str") && !payloadString.startsWith("String_Node_Str")) {
      payloadBuilder.append("String_Node_Str");
      payloadBuilder.append(payloadString);
    }
 else     if (payloadBuilder.toString().endsWith("String_Node_Str") && payloadString.startsWith("String_Node_Str")) {
      payloadBuilder.append(payloadString.substring(1));
    }
 else {
      payloadBuilder.append(payloadString);
    }
  }
}

Fixed version (ground truth):
/** 
 * Add the user defined payload String (if any). This should be of the format <key_1>=<value_1>,<key_2>=<value_2>,....<key_n>=<value_n>
 * @param payloadString String object with payload information
 */
public void populatePayload(String payloadString){
  if (payloadBuilder.toString().isEmpty()) {
    if (payloadString.startsWith("String_Node_Str")) {
      payloadBuilder.append(payloadString.substring(1));
    }
 else {
      payloadBuilder.append(payloadString);
    }
  }
 else {
    if (!payloadBuilder.toString().endsWith("String_Node_Str") && !payloadString.startsWith("String_Node_Str")) {
      payloadBuilder.append("String_Node_Str");
      payloadBuilder.append(payloadString);
    }
 else     if (payloadBuilder.toString().endsWith("String_Node_Str") && payloadString.startsWith("String_Node_Str")) {
      payloadBuilder.append(payloadString.substring(1));
    }
 else {
      payloadBuilder.append(payloadString);
    }
  }
}