nus-yam/ex-repair huggingface dataset:
Program: 116284
Project: 116284
Buggy source:
public ApplicationInactivatedEvent(String appId){
  this.appId=appId;
}

Fixed version (ground truth):
public ApplicationInactivatedEvent(String appId,String instanceId){
  this.appId=appId;
  this.instanceId=instanceId;
}
Program: 116285
Project: 116285
Buggy source:
public ApplicationTerminatingEvent(String appId){
  this.appId=appId;
}

Fixed version (ground truth):
public ApplicationTerminatingEvent(String appId,String instanceId){
  this.appId=appId;
  this.instanceId=instanceId;
}
Program: 116286
Project: 116286
Buggy source:
private boolean doProcess(ApplicationActivatedEvent event,Applications applications){
  Application application=applications.getApplication(event.getAppId());
  if (application == null) {
    if (log.isWarnEnabled()) {
      log.warn(String.format("String_Node_Str",event.getAppId()));
    }
    return false;
  }
 else {
    if (!application.isStateTransitionValid(ApplicationStatus.Active,null)) {
      log.error("String_Node_Str" + application.getStatus(null) + "String_Node_Str"+ ApplicationStatus.Active+ "String_Node_Str");
    }
    application.setStatus(ApplicationStatus.Active,null);
  }
  notifyEventListeners(event);
  return true;
}

Fixed version (ground truth):
private boolean doProcess(ApplicationActivatedEvent event,Applications applications){
  Application application=applications.getApplication(event.getAppId());
  if (application == null) {
    if (log.isWarnEnabled()) {
      log.warn(String.format("String_Node_Str",event.getAppId()));
    }
    return false;
  }
 else {
    ApplicationInstanceContext context=application.getInstanceContexts(event.getInstanceId());
    if (context == null) {
      if (log.isWarnEnabled()) {
        log.warn(String.format("String_Node_Str" + "String_Node_Str",event.getAppId(),event.getInstanceId()));
        return false;
      }
    }
    ApplicationStatus status=ApplicationStatus.Active;
    if (!context.isStateTransitionValid(status)) {
      log.error("String_Node_Str" + context.getStatus() + "String_Node_Str"+ status+ "String_Node_Str");
    }
    context.setStatus(status);
  }
  notifyEventListeners(event);
  return true;
}
Program: 116287
Project: 116287
Buggy source:
private boolean doProcess(ApplicationInactivatedEvent event,Applications applications){
  Application application=applications.getApplication(event.getAppId());
  if (application == null) {
    if (log.isWarnEnabled()) {
      log.warn(String.format("String_Node_Str",event.getAppId()));
    }
    return false;
  }
 else {
    if (!application.isStateTransitionValid(ApplicationStatus.Inactive,null)) {
      log.error("String_Node_Str" + application.getStatus(null) + "String_Node_Str"+ ApplicationStatus.Inactive+ "String_Node_Str");
    }
    application.setStatus(ApplicationStatus.Inactive,null);
  }
  notifyEventListeners(event);
  return true;
}

Fixed version (ground truth):
private boolean doProcess(ApplicationInactivatedEvent event,Applications applications){
  Application application=applications.getApplication(event.getAppId());
  if (application == null) {
    if (log.isWarnEnabled()) {
      log.warn(String.format("String_Node_Str",event.getAppId()));
    }
    return false;
  }
 else {
    ApplicationInstanceContext context=application.getInstanceContexts(event.getInstanceId());
    if (context == null) {
      if (log.isWarnEnabled()) {
        log.warn(String.format("String_Node_Str" + "String_Node_Str",event.getAppId(),event.getInstanceId()));
        return false;
      }
    }
    ApplicationStatus status=ApplicationStatus.Inactive;
    if (!context.isStateTransitionValid(status)) {
      log.error("String_Node_Str" + context.getStatus() + "String_Node_Str"+ status+ "String_Node_Str");
    }
    context.setStatus(status);
  }
  notifyEventListeners(event);
  return true;
}
Program: 116288
Project: 116288
Buggy source:
public ParentComponentMonitor(ParentComponent component) throws DependencyBuilderException {
  aliasToActiveMonitorsMap=new HashMap<String,Monitor>();
  inactiveMonitorsList=new ArrayList<String>();
  terminatingMonitorsList=new ArrayList<String>();
  setInstanceIdToInstanceContextMap(new HashMap<String,InstanceContext>());
  this.id=component.getUniqueIdentifier();
  startupDependencyTree=DependencyBuilder.getInstance().buildDependency(component);
  scalingDependencyTree=DependencyBuilder.getInstance().buildDependency(component);
}

Fixed version (ground truth):
public ParentComponentMonitor(ParentComponent component) throws DependencyBuilderException {
  aliasToActiveMonitorsMap=new HashMap<String,Monitor>();
  inactiveMonitorsList=new ArrayList<String>();
  terminatingMonitorsList=new ArrayList<String>();
  this.id=component.getUniqueIdentifier();
  startupDependencyTree=DependencyBuilder.getInstance().buildDependency(component);
  scalingDependencyTree=DependencyBuilder.getInstance().buildDependency(component);
}
Program: 116289
Project: 116289
Buggy source:
/** 
 * To start the dependency of the given application contexts
 * @param applicationContexts the found applicationContexts to be started
 */
private boolean startDependency(List<ApplicationChildContext> applicationContexts,String instanceId) throws TopologyInConsistentException {
  if (applicationContexts != null && applicationContexts.isEmpty()) {
    log.info("String_Node_Str" + this.id);
    return false;
  }
  for (  ApplicationChildContext context : applicationContexts) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + context.getId() + "String_Node_Str");
    }
    if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) {
      context.setTerminated(false);
      startMonitor(this,context,instanceId);
    }
 else {
      if (!this.instanceIdToInstanceContextMap.containsKey(instanceId)) {
        Monitor monitor=this.aliasToActiveMonitorsMap.get(context.getId());
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * To start the dependency of the given application contexts
 * @param applicationContexts the found applicationContexts to be started
 */
private boolean startDependency(List<ApplicationChildContext> applicationContexts,String instanceId) throws TopologyInConsistentException {
  if (applicationContexts != null && applicationContexts.isEmpty()) {
    log.info("String_Node_Str" + this.id);
    return false;
  }
  for (  ApplicationChildContext context : applicationContexts) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + context.getId() + "String_Node_Str");
    }
    if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) {
      context.setTerminated(false);
      startMonitor(this,context,instanceId);
    }
 else {
    }
  }
  return true;
}
Program: 116290
Project: 116290
Buggy source:
@Override public synchronized void connectionLost(Throwable cause){
  log.warn("String_Node_Str" + topicName,cause);
  if (mqttClient.isConnected()) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str");
    }
    return;
  }
  log.info("String_Node_Str" + topicName);
  create();
  connect();
  subscribe();
  log.info("String_Node_Str" + topicName);
}

Fixed version (ground truth):
@Override public synchronized void connectionLost(Throwable cause){
  if (log.isWarnEnabled()) {
    log.warn("String_Node_Str" + topicName,cause);
  }
  if (mqttClient.isConnected()) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str");
    }
    return;
  }
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + topicName);
  }
  create();
  connect();
  subscribe();
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + topicName);
  }
}
Program: 116291
Project: 116291
Buggy source:
@Override public void disconnect(){
  try {
synchronized (mqttClient) {
      if (mqttClient.isConnected()) {
        mqttClient.disconnect();
      }
    }
  }
 catch (  MqttException e) {
    String errorMsg="String_Node_Str";
    log.error(errorMsg,e);
  }
  closeConnection();
}

Fixed version (ground truth):
/** 
 * Disconnect from message broker and close the connection.
 */
@Override public void disconnect(){
  try {
    if (mqttClient == null) {
      if (log.isWarnEnabled()) {
        log.warn("String_Node_Str");
      }
      return;
    }
synchronized (mqttClient) {
      if (mqttClient.isConnected()) {
        mqttClient.disconnect();
      }
      closeConnection();
    }
  }
 catch (  Exception e) {
    String errorMsg="String_Node_Str";
    log.error(errorMsg,e);
  }
}
Program: 116292
Project: 116292
Buggy source:
@Override public void subscribe(){
  try {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + topicName);
    }
    mqttClient.setCallback(new MQTTSubscriberCallback());
    mqttClient.subscribe(topicName,MqttConstants.QOS);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + topicName);
    }
  }
 catch (  MqttException e) {
    String errorMsg="String_Node_Str" + topicName;
    log.error(errorMsg,e);
  }
}

Fixed version (ground truth):
/** 
 * Subscribe to topic.
 */
@Override public void subscribe(){
  try {
    if (mqttClient == null) {
      if (log.isWarnEnabled()) {
        log.warn("String_Node_Str");
      }
      return;
    }
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + topicName);
    }
    mqttClient.setCallback(new MQTTSubscriberCallback());
    mqttClient.subscribe(topicName,MqttConstants.QOS);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + topicName);
    }
  }
 catch (  Exception e) {
    String errorMsg="String_Node_Str" + topicName;
    log.error(errorMsg,e);
  }
}
Program: 116293
Project: 116293
Buggy source:
@Override public void create(){
  try {
    String mqttUrl=MqttConstants.MQTT_PROPERTIES.getProperty("String_Node_Str",MqttConstants.MQTT_URL_DEFAULT);
    MemoryPersistence memoryPersistence=new MemoryPersistence();
    String clientId=Util.getRandomString(23);
    mqttClient=new MqttClient(mqttUrl,clientId,memoryPersistence);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + clientId);
    }
  }
 catch (  Exception e) {
    String message="String_Node_Str";
    log.error(message,e);
    throw new MessagingException(message,e);
  }
}

Fixed version (ground truth):
/** 
 * Create MQTT client object with required configuration.
 */
@Override public void create(){
  try {
    String mqttUrl=MqttConstants.MQTT_PROPERTIES.getProperty("String_Node_Str",MqttConstants.MQTT_URL_DEFAULT);
    MemoryPersistence memoryPersistence=new MemoryPersistence();
    String clientId=Util.getRandomString(23);
    mqttClient=new MqttClient(mqttUrl,clientId,memoryPersistence);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + clientId);
    }
  }
 catch (  Exception e) {
    String message="String_Node_Str";
    log.error(message,e);
    throw new MessagingException(message,e);
  }
}
Program: 116294
Project: 116294
Buggy source:
@Override public String getServerURI(){
  return mqttClient.getServerURI();
}

Fixed version (ground truth):
/** 
 * Return server URI.
 * @return
 */
@Override public String getServerURI(){
  return mqttClient.getServerURI();
}
Program: 116295
Project: 116295
Buggy source:
@Override public void connect(){
  try {
    MqttConnectOptions connectOptions=new MqttConnectOptions();
    connectOptions.setCleanSession(true);
    mqttClient.connect(connectOptions);
  }
 catch (  Exception e) {
    String message="String_Node_Str";
    log.error(message,e);
    throw new MessagingException(message,e);
  }
}

Fixed version (ground truth):
/** 
 * Connect to message broker using MQTT client object created.
 */
@Override public void connect(){
  try {
    if (mqttClient == null) {
      if (log.isWarnEnabled()) {
        log.warn("String_Node_Str");
      }
      return;
    }
    MqttConnectOptions connectOptions=new MqttConnectOptions();
    connectOptions.setCleanSession(true);
    mqttClient.connect(connectOptions);
  }
 catch (  Exception e) {
    String message="String_Node_Str";
    log.error(message,e);
    throw new MessagingException(message,e);
  }
}
Program: 116296
Project: 116296
Buggy source:
private void closeConnection(){
  try {
    if (mqttClient != null) {
      mqttClient.close();
    }
  }
 catch (  MqttException e) {
    String message="String_Node_Str";
    log.error(message,e);
  }
 finally {
    mqttClient=null;
  }
}

Fixed version (ground truth):
private void closeConnection(){
  try {
    if (mqttClient == null) {
      if (log.isWarnEnabled()) {
        log.warn("String_Node_Str");
      }
      return;
    }
    mqttClient.close();
  }
 catch (  Exception e) {
    String message="String_Node_Str";
    log.error(message,e);
  }
 finally {
    mqttClient=null;
  }
}
Program: 116297
Project: 116297
Buggy source:
/** 
 * Adds InstanceContext of a child to the aliasAndInstanceIdToInstanceContextMap, after initializing the map if not already done.
 * @param alias alias of child
 * @param instanceId instance id of child
 * @param instanceContext InstanceContext object
 */
public void addInstanceContext(String alias,String instanceId,InstanceContext instanceContext){
  if (aliasAndInstanceIdToInstanceContextMap == null) {
synchronized (this) {
      if (aliasAndInstanceIdToInstanceContextMap == null) {
        aliasAndInstanceIdToInstanceContextMap=new HashMap<AliasAndInstanceId,InstanceContext>();
      }
    }
  }
  aliasAndInstanceIdToInstanceContextMap.put(new AliasAndInstanceId(alias,instanceId),instanceContext);
}

Fixed version (ground truth):
/** 
 * Adds InstanceContext of a child to the aliasAndInstanceIdToInstanceContextMap.
 * @param alias alias of child
 * @param instanceId instance id of child
 * @param instanceContext InstanceContext object
 */
public void addInstanceContext(String alias,String instanceId,InstanceContext instanceContext){
  aliasAndInstanceIdToInstanceContextMap.put(new AliasAndInstanceId(alias,instanceId),instanceContext);
}
Program: 116298
Project: 116298
Buggy source:
/** 
 * Retrieves InstanceContext obj. for the given alias and instance id
 * @param alias alias
 * @param instanceId instance id
 * @return InstanceContext obj if exists, else null
 */
public InstanceContext getInstanceContext(String alias,String instanceId){
  if (aliasAndInstanceIdToInstanceContextMap == null) {
    return null;
  }
  return aliasAndInstanceIdToInstanceContextMap.get(new AliasAndInstanceId(alias,instanceId));
}

Fixed version (ground truth):
/** 
 * Retrieves InstanceContext obj. for the given alias and instance id
 * @param alias alias
 * @param instanceId instance id
 * @return InstanceContext obj if exists, else null
 */
public InstanceContext getInstanceContext(String alias,String instanceId){
  return aliasAndInstanceIdToInstanceContextMap.get(new AliasAndInstanceId(alias,instanceId));
}
Program: 116299
Project: 116299
Buggy source:
private void reconnect(){
  boolean reconnected=false;
  while (!reconnected) {
    try {
      if (log.isInfoEnabled()) {
        log.info("String_Node_Str" + Util.getFailoverPingInterval() / 1000 + "String_Node_Str");
      }
      try {
        Thread.sleep(Util.getFailoverPingInterval());
      }
 catch (      InterruptedException ignore) {
      }
      if (log.isInfoEnabled()) {
        log.info("String_Node_Str" + topicName);
      }
      create();
      connect();
      subscribe();
    }
 catch (    Exception e) {
      if (log.isErrorEnabled()) {
        log.error("String_Node_Str",e);
      }
    }
  }
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + topicName);
  }
}

Fixed version (ground truth):
private void reconnect(){
  boolean reconnected=false;
  while (!reconnected) {
    try {
      if (log.isInfoEnabled()) {
        log.info("String_Node_Str" + Util.getFailoverPingInterval() / 1000 + "String_Node_Str");
      }
      try {
        Thread.sleep(Util.getFailoverPingInterval());
      }
 catch (      InterruptedException ignore) {
      }
      if (log.isInfoEnabled()) {
        log.info("String_Node_Str" + topicName);
      }
      create();
      connect();
      subscribe();
      reconnected=true;
    }
 catch (    Exception e) {
      if (log.isErrorEnabled()) {
        log.error("String_Node_Str",e);
      }
    }
  }
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + topicName);
  }
}
Program: 116300
Project: 116300
Buggy source:
/** 
 * Subscribe to topic.
 */
@Override public void subscribe(){
  try {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + topicName);
    }
    if (mqttClient == null) {
      String error="String_Node_Str";
      if (log.isErrorEnabled()) {
        log.error(error);
      }
      throw new MessagingException(error);
    }
    mqttClient.setCallback(new MQTTSubscriberCallback());
    mqttClient.subscribe(topicName,MqttConstants.QOS);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + topicName);
    }
  }
 catch (  Exception e) {
    String errorMsg="String_Node_Str" + topicName;
    log.error(errorMsg,e);
  }
}

Fixed version (ground truth):
/** 
 * Subscribe to topic.
 */
@Override public void subscribe(){
  try {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + topicName);
    }
    if (mqttClient == null) {
      String error="String_Node_Str";
      if (log.isErrorEnabled()) {
        log.error(error);
      }
      throw new MessagingException(error);
    }
    mqttClient.setCallback(new MQTTSubscriberCallback());
    mqttClient.subscribe(topicName,MqttConstants.QOS);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + topicName);
    }
  }
 catch (  Exception e) {
    String errorMsg="String_Node_Str" + topicName;
    log.error(errorMsg,e);
    throw new MessagingException(errorMsg,e);
  }
}
Program: 116302
Project: 116302
Buggy source:
public static String encryptPassword(String repoUserPassword,String secKey){
  String encryptPassword="String_Node_Str";
  String secret=secKey;
  SecretKey key;
  Cipher cipher;
  Base64 coder;
  key=new SecretKeySpec(secret.getBytes(),"String_Node_Str");
  try {
    cipher=Cipher.getInstance("String_Node_Str","String_Node_Str");
    coder=new Base64();
    cipher.init(Cipher.ENCRYPT_MODE,key);
    byte[] cipherText=cipher.doFinal(repoUserPassword.getBytes());
    encryptPassword=new String(coder.encode(cipherText));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return encryptPassword;
}

Fixed version (ground truth):
public static String encryptPassword(String repoUserPassword,String secKey){
  String encryptPassword="String_Node_Str";
  SecretKey key;
  Cipher cipher;
  Base64 coder;
  key=new SecretKeySpec(secKey.getBytes(),"String_Node_Str");
  try {
    cipher=Cipher.getInstance("String_Node_Str","String_Node_Str");
    coder=new Base64();
    cipher.init(Cipher.ENCRYPT_MODE,key);
    byte[] cipherText=cipher.doFinal(repoUserPassword.getBytes());
    encryptPassword=new String(coder.encode(cipherText));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return encryptPassword;
}
Program: 116305
Project: 116305
Buggy source:
@Override public void onChildScalingEvent(MonitorScalingEvent scalingEvent){
  GroupChildContext currentChildContextInScalingTree=(GroupChildContext)scalingDependencyTree.findApplicationContextWithIdInScalingDependencyTree(id);
  if (currentChildContextInScalingTree.hasScalingDependents()) {
    for (    ApplicationChildContext applicationChildContext : currentChildContextInScalingTree.getApplicationChildContextList()) {
      Monitor monitor=aliasToActiveMonitorsMap.get(applicationChildContext.getId());
      if (monitor instanceof GroupMonitor || monitor instanceof ApplicationMonitor) {
        monitor.onParentScalingEvent(scalingEvent);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onChildScalingEvent(MonitorScalingEvent scalingEvent){
  GroupChildContext currentChildContextInScalingTree=(GroupChildContext)scalingDependencyTree.findApplicationContextWithIdInScalingDependencyTree(id);
  if (currentChildContextInScalingTree.isGroupScalingEnabled()) {
    for (    ApplicationChildContext applicationChildContext : currentChildContextInScalingTree.getApplicationChildContextList()) {
      Monitor monitor=aliasToActiveMonitorsMap.get(applicationChildContext.getId());
      if (monitor instanceof GroupMonitor || monitor instanceof ApplicationMonitor) {
        monitor.onParentScalingEvent(scalingEvent);
      }
    }
  }
}
Program: 116306
Project: 116306
Buggy source:
public void setTerminationBehaviour(String killBehaviour){
  this.terminationBehaviour=killBehaviour;
}

Fixed version (ground truth):
public void setTerminationBehaviour(String terminationBehaviour){
  this.terminationBehaviour=terminationBehaviour;
}
Program: 116307
Project: 116307
Buggy source:
public ServiceGroup[] getServiceGroups() throws RemoteException {
  return stub.getServiceGroups();
}

Fixed version (ground truth):
public ServiceGroup[] getServiceGroups() throws RemoteException, AutoScalerServiceAutoScalerExceptionException {
  return stub.getServiceGroups();
}
Program: 116308
Project: 116308
Buggy source:
public ServiceGroupDefinition[] getServiceGroupDefinitions() throws ADCException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  AutoscalerServiceClient asServiceClient;
  try {
    asServiceClient=AutoscalerServiceClient.getServiceClient();
    ServiceGroup[] serviceGroups=asServiceClient.getServiceGroups();
    if (serviceGroups == null || serviceGroups.length == 0) {
      return null;
    }
    ServiceGroupDefinition[] serviceGroupDefinitions=new ServiceGroupDefinition[serviceGroups.length];
    for (int i=0; i < serviceGroups.length; i++) {
      serviceGroupDefinitions[i]=populateServiceGroupDefinitionPojo(serviceGroups[i]);
    }
    return serviceGroupDefinitions;
  }
 catch (  AxisFault axisFault) {
    throw new ADCException(axisFault);
  }
catch (  RemoteException e) {
    throw new ADCException(e);
  }
}

Fixed version (ground truth):
public ServiceGroupDefinition[] getServiceGroupDefinitions() throws ADCException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  AutoscalerServiceClient asServiceClient;
  try {
    asServiceClient=AutoscalerServiceClient.getServiceClient();
    ServiceGroup[] serviceGroups=asServiceClient.getServiceGroups();
    if (serviceGroups == null || serviceGroups.length == 0) {
      return null;
    }
    ServiceGroupDefinition[] serviceGroupDefinitions=new ServiceGroupDefinition[serviceGroups.length];
    for (int i=0; i < serviceGroups.length; i++) {
      serviceGroupDefinitions[i]=populateServiceGroupDefinitionPojo(serviceGroups[i]);
    }
    return serviceGroupDefinitions;
  }
 catch (  AxisFault axisFault) {
    throw new ADCException(axisFault);
  }
catch (  RemoteException e) {
    throw new ADCException(e);
  }
catch (  AutoScalerServiceAutoScalerExceptionException e) {
    e.printStackTrace();
    return null;
  }
}
Program: 116309
Project: 116309
Buggy source:
public static void handleGroupActivatedEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupStatus status=GroupStatus.Active;
  if (group.isStateTransitionValid(status)) {
    log.info(String.format("String_Node_Str",groupId,status));
    group.setStatus(status);
    updateGroupMonitor(appId,groupId,status);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",groupId,group.getStatus(),status));
  }
  ApplicationHolder.persistApplication(application);
}

Fixed version (ground truth):
public static void handleGroupActivatedEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupStatus status=GroupStatus.Active;
  if (group.isStateTransitionValid(status)) {
    group.setStatus(status);
    updateGroupMonitor(appId,groupId,status);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendGroupActivatedEvent(appId,groupId);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",groupId,group.getStatus(),status));
  }
}
Program: 116310
Project: 116310
Buggy source:
public static void handleGroupTerminatingEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  try {
    ApplicationHolder.acquireWriteLock();
    GroupStatus status=GroupStatus.Terminating;
    if (group.isStateTransitionValid(status)) {
      log.info("String_Node_Str" + status + "String_Node_Str"+ group.getUniqueIdentifier());
      group.setStatus(status);
      updateGroupMonitor(appId,groupId,status);
    }
 else {
      log.warn("String_Node_Str" + groupId + "String_Node_Str"+ group.getStatus()+ "String_Node_Str"+ status);
    }
    ApplicationHolder.persistApplication(application);
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
}

Fixed version (ground truth):
public static void handleGroupTerminatingEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  try {
    ApplicationHolder.acquireWriteLock();
    GroupStatus status=GroupStatus.Terminating;
    if (group.isStateTransitionValid(status)) {
      group.setStatus(status);
      updateGroupMonitor(appId,groupId,status);
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendGroupTerminatingEvent(appId,groupId);
    }
 else {
      log.warn("String_Node_Str" + groupId + "String_Node_Str"+ group.getStatus()+ "String_Node_Str"+ status);
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
}
Program: 116311
Project: 116311
Buggy source:
public static void handleApplicationTerminatingEvent(String applicationId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + applicationId);
  }
  ApplicationHolder.acquireWriteLock();
  try {
    Applications applications=ApplicationHolder.getApplications();
    if (!applications.applicationExists(applicationId)) {
      log.warn("String_Node_Str" + applicationId);
      return;
    }
    Application application=applications.getApplication(applicationId);
    ApplicationStatus status=ApplicationStatus.Terminating;
    if (application.isStateTransitionValid(status)) {
      log.info(String.format("String_Node_Str",applicationId,status));
      application.setStatus(status);
      updateApplicationMonitor(applicationId,status);
      ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId);
    }
 else {
      log.warn(String.format("String_Node_Str" + "String_Node_Str",applicationId,application.getStatus(),status));
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
}

Fixed version (ground truth):
public static void handleApplicationTerminatingEvent(String applicationId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + applicationId);
  }
  ApplicationHolder.acquireWriteLock();
  try {
    Applications applications=ApplicationHolder.getApplications();
    if (!applications.applicationExists(applicationId)) {
      log.warn("String_Node_Str" + applicationId);
      return;
    }
    Application application=applications.getApplication(applicationId);
    ApplicationStatus status=ApplicationStatus.Terminating;
    if (application.isStateTransitionValid(status)) {
      application.setStatus(status);
      updateApplicationMonitor(applicationId,status);
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId);
    }
 else {
      log.warn(String.format("String_Node_Str" + "String_Node_Str",applicationId,application.getStatus(),status));
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
}
Program: 116312
Project: 116312
Buggy source:
public static void handleGroupTerminatedEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupStatus status=GroupStatus.Terminated;
  if (group.isStateTransitionValid(status)) {
    log.info(String.format("String_Node_Str",groupId,status));
    group.setStatus(status);
    updateGroupMonitor(appId,groupId,status);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",groupId,group.getStatus(),status));
  }
  ApplicationHolder.persistApplication(application);
}

Fixed version (ground truth):
public static void handleGroupTerminatedEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupStatus status=GroupStatus.Terminated;
  if (group.isStateTransitionValid(status)) {
    group.setStatus(status);
    updateGroupMonitor(appId,groupId,status);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendGroupTerminatedEvent(appId,groupId);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",groupId,group.getStatus(),status));
  }
}
Program: 116313
Project: 116313
Buggy source:
public static void handleApplicationTerminatedEvent(String appId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  if (!applications.applicationExists(appId)) {
    log.warn("String_Node_Str" + appId);
  }
 else {
    Application application=applications.getApplication(appId);
    Set<ClusterDataHolder> clusterData=application.getClusterDataRecursively();
    ApplicationStatus status=ApplicationStatus.Terminated;
    if (application.isStateTransitionValid(status)) {
      log.info(String.format("String_Node_Str",appId,status));
      application.setStatus(status);
      updateApplicationMonitor(appId,status);
      AutoscalerContext.getInstance().removeAppMonitor(appId);
      ApplicationHolder.removeApplication(appId);
      log.info("String_Node_Str" + appId);
      ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId,clusterData);
    }
 else {
      log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,application.getStatus(),status));
    }
  }
}

Fixed version (ground truth):
public static void handleApplicationTerminatedEvent(String appId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  if (!applications.applicationExists(appId)) {
    log.warn("String_Node_Str" + appId);
  }
 else {
    Application application=applications.getApplication(appId);
    Set<ClusterDataHolder> clusterData=application.getClusterDataRecursively();
    ApplicationStatus status=ApplicationStatus.Terminated;
    if (application.isStateTransitionValid(status)) {
      application.setStatus(status);
      updateApplicationMonitor(appId,status);
      AutoscalerContext.getInstance().removeAppMonitor(appId);
      ApplicationHolder.removeApplication(appId);
      log.info("String_Node_Str" + appId);
      ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId,clusterData);
    }
 else {
      log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,application.getStatus(),status));
    }
  }
}
Program: 116314
Project: 116314
Buggy source:
public static void handleApplicationActivatedEvent(String appId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  ApplicationStatus status=ApplicationStatus.Active;
  if (application.isStateTransitionValid(status)) {
    log.info(String.format("String_Node_Str",appId,status));
    application.setStatus(status);
    updateApplicationMonitor(appId,status);
    ApplicationHolder.persistApplication(application);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,application.getStatus(),status));
  }
}

Fixed version (ground truth):
public static void handleApplicationActivatedEvent(String appId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  ApplicationStatus status=ApplicationStatus.Active;
  if (application.isStateTransitionValid(status)) {
    application.setStatus(status);
    updateApplicationMonitor(appId,status);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendApplicationActivatedEvent(appId);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,application.getStatus(),status));
  }
}
Program: 116315
Project: 116315
Buggy source:
public static void handleApplicationUndeployed(String appId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  try {
    ApplicationHolder.acquireWriteLock();
    ApplicationStatus status=ApplicationStatus.Terminating;
    if (application.isStateTransitionValid(status)) {
      log.info(String.format("String_Node_Str" + "String_Node_Str",appId,status));
      application.setStatus(status);
      updateApplicationMonitor(appId,status);
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendApplicationTerminatingEvent(appId);
    }
 else {
      log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,application.getStatus(),status));
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  ApplicationsEventPublisher.sendApplicationTerminatingEvent(appId);
}

Fixed version (ground truth):
public static void handleApplicationUndeployed(String appId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  try {
    ApplicationHolder.acquireWriteLock();
    ApplicationStatus status=ApplicationStatus.Terminating;
    if (application.isStateTransitionValid(status)) {
      application.setStatus(status);
      updateApplicationMonitor(appId,status);
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendApplicationTerminatingEvent(appId);
    }
 else {
      log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,application.getStatus(),status));
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  ApplicationsEventPublisher.sendApplicationTerminatingEvent(appId);
}
Program: 116316
Project: 116316
Buggy source:
public static void handleGroupCreatedEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupStatus status=GroupStatus.Created;
  if (group.isStateTransitionValid(status)) {
    log.info("String_Node_Str" + group.getUniqueIdentifier() + "String_Node_Str"+ status);
    group.setStatus(status);
    updateGroupMonitor(appId,groupId,status);
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ group.getStatus()+ "String_Node_Str"+ status);
  }
  ApplicationHolder.persistApplication(application);
}

Fixed version (ground truth):
public static void handleGroupCreatedEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupStatus status=GroupStatus.Created;
  if (group.isStateTransitionValid(status)) {
    group.setStatus(status);
    updateGroupMonitor(appId,groupId,status);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendGroupCreatedEvent(appId,groupId);
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ group.getStatus()+ "String_Node_Str"+ status);
  }
}
Program: 116317
Project: 116317
Buggy source:
public static void handleGroupInActivateEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupStatus status=GroupStatus.Inactive;
  if (group.isStateTransitionValid(status)) {
    log.info("String_Node_Str" + groupId + "String_Node_Str"+ status);
    group.setStatus(status);
    updateGroupMonitor(appId,groupId,status);
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ group.getStatus()+ "String_Node_Str"+ status);
  }
  ApplicationHolder.persistApplication(application);
}

Fixed version (ground truth):
public static void handleGroupInActivateEvent(String appId,String groupId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupStatus status=GroupStatus.Inactive;
  if (group.isStateTransitionValid(status)) {
    group.setStatus(status);
    updateGroupMonitor(appId,groupId,status);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendGroupInActivateEvent(appId,groupId);
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ group.getStatus()+ "String_Node_Str"+ status);
  }
}
Program: 116318
Project: 116318
Buggy source:
/** 
 * To set the status of the application monitor
 * @param status the status
 */
public void setStatus(ApplicationStatus status){
  log.info(String.format("String_Node_Str" + "String_Node_Str",id,this.status,status));
  this.status=status;
  MonitorStatusEventBuilder.notifyChildren(this,new ApplicationStatusEvent(status,appId));
}

Fixed version (ground truth):
/** 
 * To set the status of the application monitor
 * @param status the status
 */
public void setStatus(ApplicationStatus status){
  this.status=status;
  MonitorStatusEventBuilder.notifyChildren(this,new ApplicationStatusEvent(status,appId));
}
Program: 116320
Project: 116320
Buggy source:
@Override public PartitionValidator getPartitionValidator(){
  return new CloudstackPartitionValidator();
}

Fixed version (ground truth):
@Override public PartitionValidator getPartitionValidator(){
  return new CloudStackPartitionValidator();
}
Program: 116321
Project: 116321
Buggy source:
@Override public String createVolume(int sizeGB,String snapshotId){
  IaasProvider iaasInfo=getIaasProvider();
  ComputeServiceContext context=iaasInfo.getComputeService().getContext();
  String zone=ComputeServiceBuilderUtil.extractZone(iaasInfo);
  String diskOfferingID=iaasInfo.getTemplate().getOptions().as(CloudStackTemplateOptions.class).getDiskOfferingId();
  if (zone == null && diskOfferingID == null) {
    log.fatal("String_Node_Str" + zone + "String_Node_Str"+ iaasInfo);
    return null;
  }
  VolumeApi volumeApi=context.unwrapApi(CloudStackApi.class).getVolumeApi();
  Volume volume;
  if (StringUtils.isEmpty(snapshotId)) {
    if (log.isDebugEnabled()) {
      log.info("String_Node_Str" + zone);
    }
    volumeApi.createVolumeFromCustomDiskOfferingInZone(null,diskOfferingID,zone,sizeGB);
  }
 else {
    if (log.isDebugEnabled()) {
      log.info("String_Node_Str" + zone + "String_Node_Str"+ snapshotId);
    }
    volumeApi.createVolumeFromSnapshotInZone(null,diskOfferingID,zone);
  }
  return null;
}

Fixed version (ground truth):
@Override public String createVolume(int sizeGB,String snapshotId){
  IaasProvider iaasInfo=getIaasProvider();
  ComputeServiceContext context=iaasInfo.getComputeService().getContext();
  String zone=ComputeServiceBuilderUtil.extractZone(iaasInfo);
  String diskOfferingID=iaasInfo.getTemplate().getOptions().as(CloudStackTemplateOptions.class).getDiskOfferingId();
  if (zone == null && diskOfferingID == null) {
    log.error("String_Node_Str" + zone + "String_Node_Str"+ iaasInfo);
    return null;
  }
  VolumeApi volumeApi=context.unwrapApi(CloudStackApi.class).getVolumeApi();
  Volume volume;
  if (StringUtils.isEmpty(snapshotId)) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + zone);
    }
    volumeApi.createVolumeFromCustomDiskOfferingInZone(null,diskOfferingID,zone,sizeGB);
  }
 else {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + zone + "String_Node_Str"+ snapshotId);
    }
    volumeApi.createVolumeFromSnapshotInZone(null,diskOfferingID,zone);
  }
  return null;
}
Program: 116323
Project: 116323
Buggy source:
/** 
 * IMPORTANT In cloudstack we can assign public IPs, if we are using an advanced zone only. If we are using a basic zone we cannot assign public ips. <p/> When we use an advanced zone, a public IP address will get automatically assigned to the vm. So we don't need to find an unallocated IP address and assign that address to the vm (Not like in ec2 and openstack). <p/> So  this method will find the IP that has been assigned to the vm and return it.
 */
@Override public String associateAddress(NodeMetadata node){
  IaasProvider iaasInfo=getIaasProvider();
  ComputeServiceContext context=iaasInfo.getComputeService().getContext();
  CloudStackApi cloudStackApi=context.unwrapApi(CloudStackApi.class);
  String ip=null;
  ListPublicIPAddressesOptions listPublicIPAddressesOptions=new ListPublicIPAddressesOptions();
  listPublicIPAddressesOptions.zoneId(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE));
  Set<PublicIPAddress> publicIPAddresses=cloudStackApi.getAddressApi().listPublicIPAddresses(listPublicIPAddressesOptions);
  String id=node.getProviderId();
  for (  PublicIPAddress publicIPAddress : publicIPAddresses) {
    if (publicIPAddress.getVirtualMachineId().equals(id)) {
      ip=publicIPAddress.getIPAddress();
      log.debug("String_Node_Str" + ip + "String_Node_Str"+ node.getId());
      break;
    }
  }
  if (ip == null || ip.isEmpty()) {
    String msg="String_Node_Str" + node.getId();
    log.debug(msg);
    throw new CloudControllerException(msg);
  }
  return ip;
}

Fixed version (ground truth):
/** 
 * IMPORTANT In cloudstack we can assign public IPs, if we are using an advanced zone only. If we are using a basic zone we cannot assign public ips. <p/> When we use an advanced zone, a public IP address will get automatically assigned to the vm. So we don't need to find an unallocated IP address and assign that address to the vm. If you are using a basic zone you cannot assign public IPs <p/> So  this method will find the IP that has been assigned to the vm and return it.
 */
@Override public String associateAddress(NodeMetadata node){
  IaasProvider iaasInfo=getIaasProvider();
  ComputeServiceContext context=iaasInfo.getComputeService().getContext();
  CloudStackApi cloudStackApi=context.unwrapApi(CloudStackApi.class);
  String ip=null;
  ListPublicIPAddressesOptions listPublicIPAddressesOptions=new ListPublicIPAddressesOptions();
  listPublicIPAddressesOptions.zoneId(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE));
  Set<PublicIPAddress> publicIPAddresses=cloudStackApi.getAddressApi().listPublicIPAddresses(listPublicIPAddressesOptions);
  String id=node.getProviderId();
  for (  PublicIPAddress publicIPAddress : publicIPAddresses) {
    if (publicIPAddress.getVirtualMachineId().equals(id)) {
      ip=publicIPAddress.getIPAddress();
      log.info("String_Node_Str" + ip + "String_Node_Str"+ node.getId());
      break;
    }
  }
  if (ip == null || ip.isEmpty()) {
    String msg="String_Node_Str" + node.getId();
    log.warn(msg);
    throw new CloudControllerException(msg);
  }
  return ip;
}