nus-yam/ex-repair huggingface dataset:
Program: 116208
Project: 116208
Buggy source:
/** 
 * Will set the status of the monitor based on Topology Group status/child status like scaling
 * @param status status of the group
 */
public void setStatus(GroupStatus status,String instanceId){
  this.groupInstanceIdMap.get(instanceId).setStatus(status);
  if (status == GroupStatus.Inactive && !this.hasStartupDependents) {
    log.info("String_Node_Str" + this.id + "String_Node_Str"+ "String_Node_Str");
  }
 else {
    log.info("String_Node_Str" + this.id + "String_Node_Str"+ this.parent.getId());
    if (this.isGroupScalingEnabled()) {
      ApplicationHolder.acquireReadLock();
      try {
        Application application=ApplicationHolder.getApplications().getApplication(this.appId);
        if (application != null) {
          Group group=application.getGroupRecursively(this.id);
          if (group != null) {
            GroupInstance context=group.getInstanceContexts(instanceId);
            MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent,status,this.id,context.getParentId());
          }
        }
      }
  finally {
        ApplicationHolder.releaseReadLock();
      }
    }
 else {
      MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent,status,this.id,instanceId);
    }
  }
  try {
    MonitorStatusEventBuilder.notifyChildren(this,new GroupStatusEvent(status,this.id,instanceId));
  }
 catch (  ParentMonitorNotFoundException e) {
    log.error("String_Node_Str" + this.id,e);
  }
}

Fixed version (ground truth):
/** 
 * Will set the status of the monitor based on Topology Group status/child status like scaling
 * @param status status of the group
 */
public void setStatus(GroupStatus status,String instanceId){
  this.groupInstanceIdMap.get(instanceId).setStatus(status);
  if (status == GroupStatus.Inactive && !this.hasStartupDependents) {
    log.info("String_Node_Str" + this.id + "String_Node_Str"+ "String_Node_Str");
  }
 else {
    log.info("String_Node_Str" + this.id + "String_Node_Str"+ this.parent.getId());
    if (this.isGroupScalingEnabled()) {
      ApplicationHolder.acquireReadLock();
      try {
        Application application=ApplicationHolder.getApplications().getApplication(this.appId);
        if (application != null) {
          Group group=application.getGroupRecursively(this.id);
          if (group != null) {
            GroupInstance context=group.getInstanceContexts(instanceId);
            MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent,status,this.id,context.getParentId());
          }
        }
      }
  finally {
        ApplicationHolder.releaseReadLock();
      }
    }
 else {
      MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent,status,this.id,instanceId);
    }
  }
  try {
    MonitorStatusEventBuilder.notifyChildren(this,new GroupStatusEvent(status,this.id,instanceId));
  }
 catch (  MonitorNotFoundException e) {
    log.error("String_Node_Str" + this.id,e);
  }
}
Program: 116209
Project: 116209
Buggy source:
@Override public void onParentStatusEvent(MonitorStatusEvent statusEvent) throws ParentMonitorNotFoundException {
  String instanceId=statusEvent.getInstanceId();
  if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) {
    ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId);
  }
 else   if (statusEvent.getStatus() == ClusterStatus.Created || statusEvent.getStatus() == GroupStatus.Created) {
    Application application=ApplicationHolder.getApplications().getApplication(this.appId);
    Group group=application.getGroupRecursively(statusEvent.getId());
    createInstanceAndStartDependency(group,statusEvent.getInstanceId());
  }
}

Fixed version (ground truth):
@Override public void onParentStatusEvent(MonitorStatusEvent statusEvent) throws MonitorNotFoundException {
  String instanceId=statusEvent.getInstanceId();
  if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) {
    ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId);
  }
 else   if (statusEvent.getStatus() == ClusterStatus.Created || statusEvent.getStatus() == GroupStatus.Created) {
    Application application=ApplicationHolder.getApplications().getApplication(this.appId);
    Group group=application.getGroupRecursively(statusEvent.getId());
    createInstanceAndStartDependency(group,statusEvent.getInstanceId());
  }
}
Program: 116210
Project: 116210
Buggy source:
/** 
 * This will start the parallel dependencies at once from the top level. it will get invoked when the monitor starts up only.
 */
public boolean startDependencyByInstanceCreation(String childId,String instanceId) throws ParentMonitorNotFoundException {
  List<ApplicationChildContext> applicationContexts=this.startupDependencyTree.getStarAbleDependencies(childId);
  return startDependency(applicationContexts,instanceId);
}

Fixed version (ground truth):
/** 
 * This will start the parallel dependencies at once from the top level. it will get invoked when the monitor starts up only.
 */
public boolean startDependencyByInstanceCreation(String childId,String instanceId) throws MonitorNotFoundException {
  List<ApplicationChildContext> applicationContexts=this.startupDependencyTree.getStarAbleDependencies(childId);
  return startDependency(applicationContexts,instanceId);
}
Program: 116211
Project: 116211
Buggy source:
/** 
 * This will start the child monitors based on the active of siblings according to start up order
 * @param eventId parent id of the event which received
 */
protected void onChildActivatedEvent(String eventId,String instanceId){
  try {
    if (this.inactiveMonitorsList.contains(eventId)) {
      this.inactiveMonitorsList.remove(eventId);
    }
    if (this.terminatingMonitorsList.contains(eventId)) {
      this.terminatingMonitorsList.remove(eventId);
    }
    boolean startDep;
    if (!aliasToActiveMonitorsMap.containsKey(eventId)) {
      startDep=startDependency(eventId,instanceId);
    }
 else {
      startDep=startDependencyByInstanceCreation(eventId,instanceId);
    }
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + startDep + "String_Node_Str"+ eventId);
    }
    if (!startDep) {
      StatusChecker.getInstance().onChildStatusChange(eventId,this.id,this.appId,instanceId);
    }
  }
 catch (  ParentMonitorNotFoundException e) {
    log.error(e);
  }
}

Fixed version (ground truth):
/** 
 * This will start the child monitors based on the active of siblings according to start up order
 * @param eventId parent id of the event which received
 */
protected void onChildActivatedEvent(String eventId,String instanceId){
  try {
    if (this.inactiveMonitorsList.contains(eventId)) {
      this.inactiveMonitorsList.remove(eventId);
    }
    if (this.terminatingMonitorsList.contains(eventId)) {
      this.terminatingMonitorsList.remove(eventId);
    }
    boolean startDep;
    if (!aliasToActiveMonitorsMap.containsKey(eventId)) {
      startDep=startDependency(eventId,instanceId);
    }
 else {
      startDep=startDependencyByInstanceCreation(eventId,instanceId);
    }
    if (!startDep) {
      ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
    }
 else {
      log.info("String_Node_Str" + startDep + "String_Node_Str"+ eventId);
    }
  }
 catch (  MonitorNotFoundException e) {
    log.error(e);
  }
}
Program: 116212
Project: 116212
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 ParentMonitorNotFoundException {
  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())) {
      String msg="String_Node_Str";
      throw new ParentMonitorNotFoundException(msg);
    }
 else {
      Monitor monitor=aliasToActiveMonitorsMap.get(context.getId());
      if (context instanceof ClusterChildContext) {
        MonitorStatusEventBuilder.notifyChildCluster(monitor,ClusterStatus.Created,instanceId);
      }
 else       if (context instanceof GroupChildContext) {
        MonitorStatusEventBuilder.notifyChildGroup(monitor,GroupStatus.Created,instanceId);
      }
    }
  }
  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 MonitorNotFoundException {
  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())) {
      String msg="String_Node_Str";
      throw new MonitorNotFoundException(msg);
    }
 else {
      Monitor monitor=aliasToActiveMonitorsMap.get(context.getId());
      if (context instanceof ClusterChildContext) {
        MonitorStatusEventBuilder.notifyChildCluster(monitor,ClusterStatus.Created,instanceId);
      }
 else       if (context instanceof GroupChildContext) {
        MonitorStatusEventBuilder.notifyChildGroup(monitor,GroupStatus.Created,instanceId);
      }
    }
  }
  return true;
}
Program: 116213
Project: 116213
Buggy source:
public static void notifyChildGroup(Monitor child,GroupStatus state,String instanceId) throws ParentMonitorNotFoundException {
  MonitorStatusEvent statusEvent=new GroupStatusEvent(state,child.getId(),instanceId);
  child.onParentStatusEvent(statusEvent);
}

Fixed version (ground truth):
public static void notifyChildGroup(Monitor child,GroupStatus state,String instanceId) throws MonitorNotFoundException {
  MonitorStatusEvent statusEvent=new GroupStatusEvent(state,child.getId(),instanceId);
  child.onParentStatusEvent(statusEvent);
}
Program: 116214
Project: 116214
Buggy source:
public static void notifyChildCluster(Monitor child,ClusterStatus state,String instanceId) throws ParentMonitorNotFoundException {
  MonitorStatusEvent statusEvent=new ClusterStatusEvent(state,child.getId(),instanceId);
  child.onParentStatusEvent(statusEvent);
}

Fixed version (ground truth):
public static void notifyChildCluster(Monitor child,ClusterStatus state,String instanceId) throws MonitorNotFoundException {
  MonitorStatusEvent statusEvent=new ClusterStatusEvent(state,child.getId(),instanceId);
  child.onParentStatusEvent(statusEvent);
}
Program: 116215
Project: 116215
Buggy source:
private boolean doProcess(String idOfComponent,String appId,String instanceId){
  ParentComponent component;
  Map<String,Group> groups;
  Map<String,ClusterDataHolder> clusterData;
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + idOfComponent + "String_Node_Str");
  }
  try {
    ApplicationHolder.acquireWriteLock();
    if (idOfComponent.equals(appId)) {
      component=ApplicationHolder.getApplications().getApplication(appId);
    }
 else {
      component=ApplicationHolder.getApplications().getApplication(appId).getGroupRecursively(idOfComponent);
    }
    groups=component.getAliasToGroupMap();
    clusterData=component.getClusterDataMap();
    if (component.isGroupScalingEnabled()) {
    }
 else {
      if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Active,instanceId) || clusterData.isEmpty() && getAllGroupInSameState(groups,GroupStatus.Active,instanceId) || getAllClusterInSameState(clusterData,ClusterStatus.Active,instanceId) && getAllGroupInSameState(groups,GroupStatus.Active,instanceId)) {
        if (component instanceof Application) {
          log.info("String_Node_Str" + appId);
          ApplicationBuilder.handleApplicationActivatedEvent(appId,instanceId);
        }
 else         if (component instanceof Group) {
          log.info("String_Node_Str" + component.getUniqueIdentifier());
          ApplicationBuilder.handleGroupActivatedEvent(appId,component.getUniqueIdentifier(),instanceId);
        }
      }
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  return true;
}

Fixed version (ground truth):
private boolean doProcess(String idOfComponent,String appId,String instanceId){
  ParentComponent component;
  Map<String,Group> groups;
  Map<String,ClusterDataHolder> clusterData;
  try {
    ApplicationHolder.acquireWriteLock();
    if (idOfComponent.equals(appId)) {
      component=ApplicationHolder.getApplications().getApplication(appId);
    }
 else {
      component=ApplicationHolder.getApplications().getApplication(appId).getGroupRecursively(idOfComponent);
    }
    groups=component.getAliasToGroupMap();
    clusterData=component.getClusterDataMap();
    if (component.isGroupScalingEnabled()) {
    }
 else {
      if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Active,instanceId) || clusterData.isEmpty() && getAllGroupInSameState(groups,GroupStatus.Active,instanceId) || getAllClusterInSameState(clusterData,ClusterStatus.Active,instanceId) && getAllGroupInSameState(groups,GroupStatus.Active,instanceId)) {
        if (component instanceof Application) {
          log.info("String_Node_Str" + appId);
          ApplicationBuilder.handleApplicationActivatedEvent(appId,instanceId);
          return true;
        }
 else         if (component instanceof Group) {
          log.info("String_Node_Str" + component.getUniqueIdentifier());
          ApplicationBuilder.handleGroupActivatedEvent(appId,component.getUniqueIdentifier(),instanceId);
          return true;
        }
      }
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  return false;
}
Program: 116216
Project: 116216
Buggy source:
private boolean doProcess(String idOfComponent,String appId,String instanceId){
  ParentComponent component;
  Map<String,Group> groups;
  Map<String,ClusterDataHolder> clusterData;
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + idOfComponent + "String_Node_Str");
  }
  try {
    ApplicationHolder.acquireWriteLock();
    if (idOfComponent.equals(appId)) {
      component=ApplicationHolder.getApplications().getApplication(appId);
    }
 else {
      component=ApplicationHolder.getApplications().getApplication(appId).getGroupRecursively(idOfComponent);
    }
    groups=component.getAliasToGroupMap();
    clusterData=component.getClusterDataMap();
    if (groups.isEmpty() && getAllClusterInactive(clusterData,instanceId) || clusterData.isEmpty() && getAllGroupInActive(groups,instanceId) || getAllClusterInactive(clusterData,instanceId) || getAllGroupInActive(groups,instanceId)) {
      if (component instanceof Application) {
        log.warn("String_Node_Str" + appId);
      }
 else       if (component instanceof Group) {
        if (((Group)component).getStatus(null) != GroupStatus.Inactive) {
          log.info("String_Node_Str" + component.getUniqueIdentifier());
          ApplicationBuilder.handleGroupInActivateEvent(appId,component.getUniqueIdentifier(),instanceId);
        }
      }
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  return true;
}

Fixed version (ground truth):
private boolean doProcess(String idOfComponent,String appId,String instanceId){
  ParentComponent component;
  Map<String,Group> groups;
  Map<String,ClusterDataHolder> clusterData;
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + idOfComponent + "String_Node_Str");
  }
  try {
    ApplicationHolder.acquireWriteLock();
    if (idOfComponent.equals(appId)) {
      component=ApplicationHolder.getApplications().getApplication(appId);
    }
 else {
      component=ApplicationHolder.getApplications().getApplication(appId).getGroupRecursively(idOfComponent);
    }
    groups=component.getAliasToGroupMap();
    clusterData=component.getClusterDataMap();
    if (groups.isEmpty() && getAllClusterInactive(clusterData,instanceId) || clusterData.isEmpty() && getAllGroupInActive(groups,instanceId) || getAllClusterInactive(clusterData,instanceId) || getAllGroupInActive(groups,instanceId)) {
      if (component instanceof Application) {
        log.warn("String_Node_Str" + appId);
        return true;
      }
 else       if (component instanceof Group) {
        if (((Group)component).getStatus(null) != GroupStatus.Inactive) {
          log.info("String_Node_Str" + component.getUniqueIdentifier());
          ApplicationBuilder.handleGroupInActivateEvent(appId,component.getUniqueIdentifier(),instanceId);
          return true;
        }
      }
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  return false;
}
Program: 116217
Project: 116217
Buggy source:
public boolean process(String idOfComponent,String appId,String instanceId){
  GroupStatusProcessor root=(GroupStatusProcessor)list.getFirst();
  if (root == null) {
    throw new RuntimeException("String_Node_Str");
  }
  return root.process(idOfComponent,appId,instanceId);
}

Fixed version (ground truth):
public boolean process(String idOfComponent,String appId,String instanceId){
  GroupStatusProcessor root=(GroupStatusProcessor)list.getFirst();
  if (root == null) {
    throw new RuntimeException("String_Node_Str");
  }
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + "String_Node_Str" + idOfComponent + "String_Node_Str");
  }
  return root.process(idOfComponent,appId,instanceId);
}
Program: 116218
Project: 116218
Buggy source:
public static void handleApplicationUndeployed(String appId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId);
  }
  Set<ClusterDataHolder> clusterData;
  ApplicationHolder.acquireWriteLock();
  try {
    Applications applications=ApplicationHolder.getApplications();
    Application application=applications.getApplication(appId);
    if (application == null) {
      log.warn(String.format("String_Node_Str",appId));
      return;
    }
    clusterData=application.getClusterDataRecursively();
    Collection<ApplicationInstance> context=application.getInstanceIdToInstanceContextMap().values();
    ApplicationStatus status=ApplicationStatus.Terminating;
    for (    ApplicationInstance context1 : context) {
      if (context1.isStateTransitionValid(status)) {
        application.setStatus(status,context1.getInstanceId());
        updateApplicationMonitor(appId,status,context1.getInstanceId());
        ApplicationHolder.persistApplication(application);
        ApplicationsEventPublisher.sendApplicationTerminatingEvent(appId,context1.getInstanceId());
      }
 else {
        log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,context1.getInstanceId() + context1.getStatus(),status));
      }
    }
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  for (  ClusterDataHolder aClusterData : clusterData) {
    if (AutoscalerContext.getInstance().getClusterMonitor(aClusterData.getClusterId()) == null) {
      TopologyManager.acquireReadLockForCluster(aClusterData.getServiceType(),aClusterData.getClusterId());
      try {
        Service service=TopologyManager.getTopology().getService(aClusterData.getServiceType());
        if (service != null) {
          Cluster cluster=service.getCluster(aClusterData.getClusterId());
          if (cluster != null) {
          }
        }
      }
  finally {
        TopologyManager.releaseReadLockForCluster(aClusterData.getServiceType(),aClusterData.getClusterId());
      }
    }
  }
}

Fixed version (ground truth):
public static void handleApplicationUndeployed(String appId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId);
  }
  Set<ClusterDataHolder> clusterData;
  ApplicationHolder.acquireWriteLock();
  try {
    Applications applications=ApplicationHolder.getApplications();
    Application application=applications.getApplication(appId);
    if (application == null) {
      log.warn(String.format("String_Node_Str",appId));
      return;
    }
 else {
      org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy policy=PolicyManager.getInstance().getDeploymentPolicyByApplication(appId);
      if (policy != null) {
        log.warn(String.format("String_Node_Str" + "String_Node_Str",appId));
      }
    }
    ApplicationHolder.removeApplication(appId);
  }
  finally {
    ApplicationHolder.releaseWriteLock();
  }
  log.info("String_Node_Str" + appId + "String_Node_Str");
}
Program: 116219
Project: 116219
Buggy source:
public static VMServiceClusterContext getVMServiceClusterContext(String instanceId,Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  if (null == cluster) {
    return null;
  }
  String autoscalePolicyName=cluster.getAutoscalePolicyName();
  AutoscalePolicy autoscalePolicy=PolicyManager.getInstance().getAutoscalePolicy(autoscalePolicyName);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + autoscalePolicyName);
  }
  String deploymentPolicyName;
  DeploymentPolicy deploymentPolicy;
  ApplicationHolder.acquireReadLock();
  try {
    Application application=ApplicationHolder.getApplications().getApplication(cluster.getAppId());
    deploymentPolicyName=application.getDeploymentPolicy();
    deploymentPolicy=PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyName);
  }
  finally {
    ApplicationHolder.releaseReadLock();
  }
  return new VMServiceClusterContext(cluster.getClusterId(),cluster.getServiceName(),autoscalePolicy,deploymentPolicy);
}

Fixed version (ground truth):
public static VMServiceClusterContext getVMServiceClusterContext(String instanceId,Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  if (null == cluster) {
    return null;
  }
  String autoscalePolicyName=cluster.getAutoscalePolicyName();
  AutoscalePolicy autoscalePolicy=PolicyManager.getInstance().getAutoscalePolicy(autoscalePolicyName);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + autoscalePolicyName);
  }
  DeploymentPolicy deploymentPolicy;
  ApplicationHolder.acquireReadLock();
  try {
    Application application=ApplicationHolder.getApplications().getApplication(cluster.getAppId());
    deploymentPolicy=PolicyManager.getInstance().getDeploymentPolicy(cluster.getAppId());
    ChildPolicy policy=deploymentPolicy.getChildPolicy(AutoscalerUtil.getAliasFromClusterId(cluster.getClusterId()));
  }
  finally {
    ApplicationHolder.releaseReadLock();
  }
  return new VMServiceClusterContext(cluster.getClusterId(),cluster.getServiceName(),autoscalePolicy,deploymentPolicy);
}
Program: 116220
Project: 116220
Buggy source:
public ClusterInstanceContext(String clusterInstanceId,String partitionAlgo,ChildLevelPartition[] partitions,int min){
  this.id=clusterInstanceId;
  this.min=min;
  if (partitions == null) {
    this.partitions=new ChildLevelPartition[0];
  }
 else {
    this.partitions=Arrays.copyOf(partitions,partitions.length);
  }
  partitionCtxts=new ArrayList<ClusterLevelPartitionContext>();
  this.partitionAlgorithm=partitionAlgo;
  requestsInFlight=new RequestsInFlight();
  loadAverage=new LoadAverage();
  memoryConsumption=new MemoryConsumption();
  for (  ChildLevelPartition partition : partitions) {
    maxInstanceCount+=partition.getMax();
  }
  requiredInstanceCountBasedOnStats=minInstanceCount;
  requiredInstanceCountBasedOnDependencies=minInstanceCount;
}

Fixed version (ground truth):
public ClusterInstanceContext(String clusterInstanceId,String partitionAlgo,ChildLevelPartition[] partitions,int min){
  super(clusterInstanceId);
  this.min=min;
  if (partitions == null) {
    this.partitions=new ChildLevelPartition[0];
  }
 else {
    this.partitions=Arrays.copyOf(partitions,partitions.length);
  }
  partitionCtxts=new ArrayList<ClusterLevelPartitionContext>();
  this.partitionAlgorithm=partitionAlgo;
  requestsInFlight=new RequestsInFlight();
  loadAverage=new LoadAverage();
  memoryConsumption=new MemoryConsumption();
  for (  ChildLevelPartition partition : partitions) {
    maxInstanceCount+=partition.getMax();
  }
  requiredInstanceCountBasedOnStats=minInstanceCount;
  requiredInstanceCountBasedOnDependencies=minInstanceCount;
}
Program: 116222
Project: 116222
Buggy source:
public void addInstanceContext(String instanceId,Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  ClusterLevelNetworkPartitionContext networkPartitionContext=null;
  ClusterInstance clusterInstance=cluster.getInstanceContexts(instanceId);
  if (networkPartitionCtxts.containsKey(clusterInstance.getNetworkPartitionId())) {
    networkPartitionContext=this.networkPartitionCtxts.get(clusterInstance.getNetworkPartitionId());
  }
  if (clusterInstance.getPartitionId() != null) {
    networkPartitionContext=addPartition(clusterInstance,cluster,this.deploymentPolicy,networkPartitionContext);
  }
 else {
    networkPartitionContext=parseDeploymentPolicy(clusterInstance,cluster,this.deploymentPolicy,networkPartitionContext);
  }
  if (!networkPartitionCtxts.containsKey(clusterInstance.getNetworkPartitionId())) {
    this.networkPartitionCtxts.put(clusterInstance.getNetworkPartitionId(),networkPartitionContext);
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str" + "String_Node_Str",clusterInstance.getNetworkPartitionId()));
    }
  }
}

Fixed version (ground truth):
public void addInstanceContext(String instanceId,Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  ClusterLevelNetworkPartitionContext networkPartitionContext=null;
  ClusterInstance clusterInstance=cluster.getInstanceContexts(instanceId);
  if (networkPartitionCtxts.containsKey(clusterInstance.getNetworkPartitionId())) {
    networkPartitionContext=this.networkPartitionCtxts.get(clusterInstance.getNetworkPartitionId());
  }
  if (clusterInstance.getPartitionId() != null) {
    networkPartitionContext=addPartition(clusterInstance,cluster,networkPartitionContext);
  }
 else {
    ChildPolicy policy=this.deploymentPolicy.getChildPolicy(AutoscalerUtil.getAliasFromClusterId(clusterId));
    networkPartitionContext=parseDeploymentPolicy(clusterInstance,cluster,policy,networkPartitionContext);
  }
  if (!networkPartitionCtxts.containsKey(clusterInstance.getNetworkPartitionId())) {
    this.networkPartitionCtxts.put(clusterInstance.getNetworkPartitionId(),networkPartitionContext);
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str" + "String_Node_Str",clusterInstance.getNetworkPartitionId()));
    }
  }
}
Program: 116224
Project: 116224
Buggy source:
@Override public boolean addDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws InvalidPolicyException {
  boolean hasDeployed=PolicyManager.getInstance().deployDeploymentPolicy(deploymentPolicy);
  return hasDeployed;
}

Fixed version (ground truth):
@Override public boolean addDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws InvalidPolicyException {
  boolean hasDeployed=PolicyManager.getInstance().deployDeploymentPolicy(deploymentPolicy);
  ApplicationHolder.acquireReadLock();
  boolean allClusterInitialized=false;
  try {
    Application application=ApplicationHolder.getApplications().getApplication(deploymentPolicy.getApplicationId());
    if (application != null) {
      allClusterInitialized=AutoscalerUtil.allClustersInitialized(application);
    }
  }
  finally {
    ApplicationHolder.releaseReadLock();
  }
  if (allClusterInitialized) {
    AutoscalerUtil.getInstance().startApplicationMonitor(deploymentPolicy.getApplicationId());
  }
 else {
    log.info("String_Node_Str" + "String_Node_Str");
  }
  return hasDeployed;
}
Program: 116226
Project: 116226
Buggy source:
public static VMClusterContext getVMClusterContext(String instanceId,Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  if (null == cluster) {
    return null;
  }
  String autoscalePolicyName=cluster.getAutoscalePolicyName();
  AutoscalePolicy autoscalePolicy=PolicyManager.getInstance().getAutoscalePolicy(autoscalePolicyName);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + autoscalePolicyName);
  }
  DeploymentPolicy deploymentPolicy;
  ApplicationHolder.acquireReadLock();
  try {
    Application application=ApplicationHolder.getApplications().getApplication(cluster.getAppId());
    deploymentPolicy=PolicyManager.getInstance().getDeploymentPolicy(cluster.getAppId());
    ChildPolicy policy=deploymentPolicy.getChildPolicy(AutoscalerUtil.getAliasFromClusterId(cluster.getClusterId()));
  }
  finally {
    ApplicationHolder.releaseReadLock();
  }
  return new VMClusterContext(cluster.getClusterId(),cluster.getServiceName(),autoscalePolicy,deploymentPolicy);
}

Fixed version (ground truth):
public static VMClusterContext getVMClusterContext(String instanceId,Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  if (null == cluster) {
    return null;
  }
  String autoscalePolicyName=cluster.getAutoscalePolicyName();
  AutoscalePolicy autoscalePolicy=PolicyManager.getInstance().getAutoscalePolicy(autoscalePolicyName);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + autoscalePolicyName);
  }
  DeploymentPolicy deploymentPolicy;
  ApplicationHolder.acquireReadLock();
  try {
    deploymentPolicy=PolicyManager.getInstance().getDeploymentPolicy(cluster.getAppId());
  }
  finally {
    ApplicationHolder.releaseReadLock();
  }
  return new VMClusterContext(cluster.getClusterId(),cluster.getServiceName(),autoscalePolicy,deploymentPolicy);
}
Program: 116227
Project: 116227
Buggy source:
public ClusterInstanceContext(String clusterInstanceId,String partitionAlgo,ChildLevelPartition[] partitions,int min){
  super(clusterInstanceId);
  this.min=min;
  if (partitions == null) {
    this.partitions=new ChildLevelPartition[0];
  }
 else {
    this.partitions=Arrays.copyOf(partitions,partitions.length);
  }
  partitionCtxts=new ArrayList<ClusterLevelPartitionContext>();
  this.partitionAlgorithm=partitionAlgo;
  requestsInFlight=new RequestsInFlight();
  loadAverage=new LoadAverage();
  memoryConsumption=new MemoryConsumption();
  for (  ChildLevelPartition partition : partitions) {
    maxInstanceCount+=partition.getMax();
  }
  requiredInstanceCountBasedOnStats=minInstanceCount;
  requiredInstanceCountBasedOnDependencies=minInstanceCount;
}

Fixed version (ground truth):
public ClusterInstanceContext(String clusterInstanceId,String partitionAlgo,ChildLevelPartition[] partitions,int min){
  super(clusterInstanceId);
  this.setMinMembers(min);
  if (partitions == null) {
    this.partitions=new ChildLevelPartition[0];
  }
 else {
    this.partitions=Arrays.copyOf(partitions,partitions.length);
  }
  partitionCtxts=new ArrayList<ClusterLevelPartitionContext>();
  this.partitionAlgorithm=partitionAlgo;
  requestsInFlight=new RequestsInFlight();
  loadAverage=new LoadAverage();
  memoryConsumption=new MemoryConsumption();
  for (  ChildLevelPartition partition : partitions) {
    maxInstanceCount+=partition.getMax();
  }
  requiredInstanceCountBasedOnStats=minInstanceCount;
  requiredInstanceCountBasedOnDependencies=minInstanceCount;
}
Program: 116231
Project: 116231
Buggy source:
/** 
 * Put a key value pair to a map, if clustered use a distributed lock.
 * @param map
 * @param key
 * @param value
 */
public void putToMap(Map map,Object key,Object value){
  if (clustered) {
    ILock lock=null;
    try {
      lock=acquireDistributedLock(map);
      ((IMap)map).set(key,value);
    }
  finally {
      releaseDistributedLock(lock);
    }
  }
 else {
    map.put(key,value);
  }
}

Fixed version (ground truth):
/** 
 * Put a key value pair to a map, if clustered use a distributed lock.
 * @param map
 * @param key
 * @param value
 */
public void putToMap(Map map,Object key,Object value){
  if (clustered) {
    ILock lock=null;
    try {
      IMap imap=(IMap)map;
      lock=acquireDistributedLock(imap.getName());
      imap.set(key,value);
    }
  finally {
      releaseDistributedLock(lock);
    }
  }
 else {
    map.put(key,value);
  }
}
Program: 116232
Project: 116232
Buggy source:
/** 
 * Add an object to a list, if clustered use a distributed lock.
 * @param list
 * @param value
 */
public void addToList(List list,Object value){
  if (clustered) {
    ILock lock=null;
    try {
      lock=acquireDistributedLock(list);
      ((IList)list).add(value);
    }
  finally {
      releaseDistributedLock(lock);
    }
  }
 else {
    list.add(value);
  }
}

Fixed version (ground truth):
/** 
 * Add an object to a list, if clustered use a distributed lock.
 * @param list
 * @param value
 */
public void addToList(List list,Object value){
  if (clustered) {
    ILock lock=null;
    try {
      IList ilist=(IList)list;
      lock=acquireDistributedLock(ilist.getName());
      ilist.add(value);
    }
  finally {
      releaseDistributedLock(lock);
    }
  }
 else {
    list.add(value);
  }
}
Program: 116233
Project: 116233
Buggy source:
private void releaseDistributedLock(ILock lock){
  if (log.isDebugEnabled()) {
    log.debug(String.format("String_Node_Str",lock.getKey()));
  }
  lock.forceUnlock();
  if (log.isDebugEnabled()) {
    log.debug(String.format("String_Node_Str",lock.getKey()));
  }
}

Fixed version (ground truth):
private void releaseDistributedLock(ILock lock){
  if (lock == null) {
    return;
  }
  if (log.isDebugEnabled()) {
    log.debug(String.format("String_Node_Str",lock.getKey()));
  }
  lock.forceUnlock();
  if (log.isDebugEnabled()) {
    log.debug(String.format("String_Node_Str",lock.getKey()));
  }
}
Program: 116234
Project: 116234
Buggy source:
/** 
 * Remove an object from a map, if clustered use a distributed lock.
 * @param map
 * @param key
 */
public void removeFromMap(Map map,Object key){
  if (clustered) {
    ILock lock=null;
    try {
      lock=acquireDistributedLock(map);
      ((IMap)map).delete(key);
    }
  finally {
      releaseDistributedLock(lock);
    }
  }
 else {
    map.remove(key);
  }
}

Fixed version (ground truth):
/** 
 * Remove an object from a map, if clustered use a distributed lock.
 * @param map
 * @param key
 */
public void removeFromMap(Map map,Object key){
  if (clustered) {
    ILock lock=null;
    try {
      IMap imap=(IMap)map;
      lock=acquireDistributedLock(imap.getName());
      imap.delete(key);
    }
  finally {
      releaseDistributedLock(lock);
    }
  }
 else {
    map.remove(key);
  }
}
Program: 116235
Project: 116235
Buggy source:
/** 
 * Remove an object from a list, if clustered use a distributed lock.
 * @param list
 * @param value
 */
public void removeFromList(List list,Object value){
  if (clustered) {
    ILock lock=null;
    try {
      lock=acquireDistributedLock(list);
      ((IList)list).remove(value);
    }
  finally {
      releaseDistributedLock(lock);
    }
  }
 else {
    list.remove(value);
  }
}

Fixed version (ground truth):
/** 
 * Remove an object from a list, if clustered use a distributed lock.
 * @param list
 * @param value
 */
public void removeFromList(List list,Object value){
  if (clustered) {
    ILock lock=null;
    try {
      IList ilist=(IList)list;
      lock=acquireDistributedLock(ilist.getName());
      ilist.remove(value);
    }
  finally {
      releaseDistributedLock(lock);
    }
  }
 else {
    list.remove(value);
  }
}
Program: 116236
Project: 116236
Buggy source:
@Test public void testPutToMapLocal(){
  DistributedObjectProvider provider=new DistributedObjectProvider(false,null);
  Map<String,String> map=provider.getMap("String_Node_Str");
  provider.putToMap(map,"String_Node_Str","String_Node_Str");
  assertEquals(map.get("String_Node_Str"),"String_Node_Str");
}

Fixed version (ground truth):
@Test public void testPutToMapLocal(){
  DistributedObjectProvider provider=new DistributedObjectProvider(false,null);
  testPutToMap(provider);
}
Program: 116237
Project: 116237
Buggy source:
@Test public void testAddToListLocal(){
  DistributedObjectProvider provider=new DistributedObjectProvider(false,null);
  List list=provider.getList("String_Node_Str");
  String value1="String_Node_Str";
  provider.addToList(list,value1);
  assertTrue(list.contains(value1));
}

Fixed version (ground truth):
@Test public void testAddToListLocal(){
  DistributedObjectProvider provider=new DistributedObjectProvider(false,null);
  testAddToList(provider);
}
Program: 116238
Project: 116238
Buggy source:
@Test public void testRemoveFromListLocal(){
  DistributedObjectProvider provider=new DistributedObjectProvider(false,null);
  List list=provider.getList("String_Node_Str");
  String value1="String_Node_Str";
  provider.addToList(list,value1);
  assertTrue(list.contains(value1));
  provider.removeFromList(list,value1);
  assertFalse(list.contains(value1));
}

Fixed version (ground truth):
@Test public void testRemoveFromListLocal(){
  DistributedObjectProvider provider=new DistributedObjectProvider(false,null);
  testRemovalFromList(provider);
}
Program: 116239
Project: 116239
Buggy source:
@Test public void testRemoveFromMapLocal(){
  DistributedObjectProvider provider=new DistributedObjectProvider(false,null);
  Map<String,String> map=provider.getMap("String_Node_Str");
  provider.putToMap(map,"String_Node_Str","String_Node_Str");
  assertEquals(map.get("String_Node_Str"),"String_Node_Str");
  provider.removeFromMap(map,"String_Node_Str");
  assertNull(map.get("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testRemoveFromMapLocal(){
  DistributedObjectProvider provider=new DistributedObjectProvider(false,null);
  testRemoveFromMap(provider);
}
Program: 116240
Project: 116240
Buggy source:
public static AutoscalePolicy[] getAutoScalePolicies() throws RestAPIException {
  org.apache.stratos.autoscaler.stub.policy.model.AutoscalePolicy[] autoscalePolicies=null;
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    try {
      autoscalePolicies=autoscalerServiceClient.getAutoScalePolicies();
    }
 catch (    RemoteException e) {
      String errorMsg="String_Node_Str" + e.getMessage();
      log.error(errorMsg,e);
      throw new RestAPIException(errorMsg,e);
    }
  }
  return PojoConverter.populateAutoscalePojos(autoscalePolicies);
}

Fixed version (ground truth):
public static AutoscalePolicy[] getAutoScalePolicies() throws RestAPIException {
  org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy[] autoscalePolicies=null;
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    try {
      autoscalePolicies=autoscalerServiceClient.getAutoScalePolicies();
    }
 catch (    RemoteException e) {
      String errorMsg="String_Node_Str" + e.getMessage();
      log.error(errorMsg,e);
      throw new RestAPIException(errorMsg,e);
    }
  }
  return PojoConverter.populateAutoscalePojos(autoscalePolicies);
}
Program: 116241
Project: 116241
Buggy source:
public static AutoscalePolicy getAutoScalePolicy(String autoscalePolicyId) throws RestAPIException {
  org.apache.stratos.autoscaler.stub.policy.model.AutoscalePolicy autoscalePolicy=null;
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    try {
      autoscalePolicy=autoscalerServiceClient.getAutoScalePolicy(autoscalePolicyId);
    }
 catch (    RemoteException e) {
      String errorMsg="String_Node_Str" + autoscalePolicyId + "String_Node_Str"+ e.getMessage();
      log.error(errorMsg,e);
      throw new RestAPIException(errorMsg,e);
    }
  }
  return PojoConverter.populateAutoscalePojo(autoscalePolicy);
}

Fixed version (ground truth):
public static AutoscalePolicy getAutoScalePolicy(String autoscalePolicyId) throws RestAPIException {
  org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy=null;
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    try {
      autoscalePolicy=autoscalerServiceClient.getAutoScalePolicy(autoscalePolicyId);
    }
 catch (    RemoteException e) {
      String errorMsg="String_Node_Str" + autoscalePolicyId + "String_Node_Str"+ e.getMessage();
      log.error(errorMsg,e);
      throw new RestAPIException(errorMsg,e);
    }
  }
  return PojoConverter.populateAutoscalePojo(autoscalePolicy);
}
Program: 116242
Project: 116242
Buggy source:
public static StratosApiResponse deployAutoscalingPolicy(AutoscalePolicy autoscalePolicyBean) throws RestAPIException {
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    org.apache.stratos.autoscaler.stub.policy.model.AutoscalePolicy autoscalePolicy=PojoConverter.convertToCCAutoscalerPojo(autoscalePolicyBean);
    try {
      autoscalerServiceClient.deployAutoscalingPolicy(autoscalePolicy);
    }
 catch (    RemoteException e) {
      log.error(e.getMessage(),e);
      throw new RestAPIException(e.getMessage(),e);
    }
catch (    AutoScalerServiceInvalidPolicyExceptionException e) {
      String message=e.getFaultMessage().getInvalidPolicyException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
  StratosApiResponse stratosApiResponse=new StratosApiResponse();
  stratosApiResponse.setMessage("String_Node_Str" + autoscalePolicyBean.getId());
  return stratosApiResponse;
}

Fixed version (ground truth):
public static StratosApiResponse deployAutoscalingPolicy(AutoscalePolicy autoscalePolicyBean) throws RestAPIException {
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy=PojoConverter.convertToCCAutoscalerPojo(autoscalePolicyBean);
    try {
      autoscalerServiceClient.deployAutoscalingPolicy(autoscalePolicy);
    }
 catch (    RemoteException e) {
      log.error(e.getMessage(),e);
      throw new RestAPIException(e.getMessage(),e);
    }
catch (    AutoScalerServiceInvalidPolicyExceptionException e) {
      String message=e.getFaultMessage().getInvalidPolicyException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
  StratosApiResponse stratosApiResponse=new StratosApiResponse();
  stratosApiResponse.setMessage("String_Node_Str" + autoscalePolicyBean.getId());
  return stratosApiResponse;
}
Program: 116243
Project: 116243
Buggy source:
public static AutoscalePolicy[] getAutoScalePolicies() throws RestAPIException {
  org.apache.stratos.autoscaler.stub.policy.model.AutoscalePolicy[] autoscalePolicies=null;
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    try {
      autoscalePolicies=autoscalerServiceClient.getAutoScalePolicies();
    }
 catch (    RemoteException e) {
      String errorMsg="String_Node_Str" + e.getMessage();
      log.error(errorMsg,e);
      throw new RestAPIException(errorMsg,e);
    }
  }
  return PojoConverter.populateAutoscalePojos(autoscalePolicies);
}

Fixed version (ground truth):
public static AutoscalePolicy[] getAutoScalePolicies() throws RestAPIException {
  org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy[] autoscalePolicies=null;
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    try {
      autoscalePolicies=autoscalerServiceClient.getAutoScalePolicies();
    }
 catch (    RemoteException e) {
      String errorMsg="String_Node_Str" + e.getMessage();
      log.error(errorMsg,e);
      throw new RestAPIException(errorMsg,e);
    }
  }
  return PojoConverter.populateAutoscalePojos(autoscalePolicies);
}
Program: 116244
Project: 116244
Buggy source:
public static boolean updateKubernetesHost(KubernetesHost kubernetesHostBean) throws RestAPIException {
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost kubernetesHost=PojoConverter.convertToASKubernetesHostPojo(kubernetesHostBean);
    try {
      return autoscalerServiceClient.updateKubernetesHost(kubernetesHost);
    }
 catch (    RemoteException e) {
      log.error(e.getMessage(),e);
      throw new RestAPIException(e.getMessage(),e);
    }
catch (    AutoScalerServiceInvalidKubernetesHostExceptionException e) {
      String message=e.getFaultMessage().getInvalidKubernetesHostException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
catch (    AutoScalerServiceNonExistingKubernetesHostExceptionException e) {
      String message=e.getFaultMessage().getNonExistingKubernetesHostException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean updateKubernetesHost(KubernetesHost kubernetesHostBean) throws RestAPIException {
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    org.apache.stratos.common.kubernetes.KubernetesHost kubernetesHost=PojoConverter.convertToASKubernetesHostPojo(kubernetesHostBean);
    try {
      return autoscalerServiceClient.updateKubernetesHost(kubernetesHost);
    }
 catch (    RemoteException e) {
      log.error(e.getMessage(),e);
      throw new RestAPIException(e.getMessage(),e);
    }
catch (    AutoScalerServiceInvalidKubernetesHostExceptionException e) {
      String message=e.getFaultMessage().getInvalidKubernetesHostException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
catch (    AutoScalerServiceNonExistingKubernetesHostExceptionException e) {
      String message=e.getFaultMessage().getNonExistingKubernetesHostException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
  return false;
}
Program: 116245
Project: 116245
Buggy source:
public static void updateDeploymentPolicy(org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy deploymentPolicyBean) throws RestAPIException {
  log.info(String.format("String_Node_Str",deploymentPolicyBean.getId()));
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    org.apache.stratos.autoscaler.stub.policy.model.DeploymentPolicy deploymentPolicy=PojoConverter.convetToCCDeploymentPolicyPojo(deploymentPolicyBean);
    try {
      autoscalerServiceClient.updateDeploymentPolicy(deploymentPolicy);
    }
 catch (    RemoteException e) {
      log.error(e.getMessage(),e);
      throw new RestAPIException(e.getMessage(),e);
    }
catch (    AutoScalerServiceInvalidPolicyExceptionException e) {
      String message=e.getFaultMessage().getInvalidPolicyException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
}

Fixed version (ground truth):
public static void updateDeploymentPolicy(org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy deploymentPolicyBean) throws RestAPIException {
  log.info(String.format("String_Node_Str",deploymentPolicyBean.getId()));
  AutoscalerServiceClient autoscalerServiceClient=getAutoscalerServiceClient();
  if (autoscalerServiceClient != null) {
    org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy deploymentPolicy=PojoConverter.convetToCCDeploymentPolicyPojo(deploymentPolicyBean);
    try {
      autoscalerServiceClient.updateDeploymentPolicy(deploymentPolicy);
    }
 catch (    RemoteException e) {
      log.error(e.getMessage(),e);
      throw new RestAPIException(e.getMessage(),e);
    }
catch (    AutoScalerServiceInvalidPolicyExceptionException e) {
      String message=e.getFaultMessage().getInvalidPolicyException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
}