Program: 132181
Project: 132181
Buggy source:
/** 
 * This method is called whenever there is change in a SF. Before doing any changes it takes a global lock in order to ensure it is the only writer.
 * @param change
 */
@Override public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>,DataObject> change){
  printTraceStart(LOG);
  odlSfc.getLock();
  Map<InstanceIdentifier<?>,DataObject> dataOriginalDataObject=change.getOriginalData();
  for (  Map.Entry<InstanceIdentifier<?>,DataObject> entry : dataOriginalDataObject.entrySet()) {
    if (entry.getValue() instanceof ServiceFunction) {
      ServiceFunction originalServiceFunction=(ServiceFunction)entry.getValue();
      LOG.debug("String_Node_Str",originalServiceFunction.getType(),originalServiceFunction.getName());
    }
  }
  Map<InstanceIdentifier<?>,DataObject> dataCreatedObject=change.getCreatedData();
  for (  Map.Entry<InstanceIdentifier<?>,DataObject> entry : dataCreatedObject.entrySet()) {
    if (entry.getValue() instanceof ServiceFunction) {
      ServiceFunction createdServiceFunction=(ServiceFunction)entry.getValue();
      Object[] serviceTypeObj={createdServiceFunction};
      Class[] serviceTypeClass={ServiceFunction.class};
      Future future=odlSfc.executor.submit(SfcProviderServiceTypeAPI.getCreateServiceFunctionTypeEntry(serviceTypeObj,serviceTypeClass));
      try {
        LOG.debug("String_Node_Str",future.get());
      }
 catch (      InterruptedException e) {
        LOG.warn("String_Node_Str",e);
      }
catch (      ExecutionException e) {
        LOG.warn("String_Node_Str",e);
      }
      LOG.debug("String_Node_Str",createdServiceFunction.getType(),createdServiceFunction.getName());
    }
  }
  Set<InstanceIdentifier<?>> dataRemovedConfigurationIID=change.getRemovedPaths();
  for (  InstanceIdentifier instanceIdentifier : dataRemovedConfigurationIID) {
    DataObject dataObject=dataOriginalDataObject.get(instanceIdentifier);
    if (dataObject instanceof ServiceFunction) {
      ServiceFunction originalServiceFunction=(ServiceFunction)dataObject;
      Object[] serviceFunctionObj={originalServiceFunction};
      Class[] serviceFunctionClass={ServiceFunction.class};
      Future future=odlSfc.executor.submit(SfcProviderServiceTypeAPI.getDeleteServiceFunctionFromServiceType(serviceFunctionObj,serviceFunctionClass));
      try {
        LOG.debug("String_Node_Str",future.get());
      }
 catch (      InterruptedException e) {
        LOG.warn("String_Node_Str",e);
      }
catch (      ExecutionException e) {
        LOG.warn("String_Node_Str",e);
      }
      String sfName=originalServiceFunction.getName();
      List<SfServicePath> sfServicePathList=SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor(sfName);
      List<String> rspList=new ArrayList<>();
      if ((sfServicePathList != null) && (!sfServicePathList.isEmpty())) {
        if (SfcProviderServiceFunctionAPI.deleteServiceFunctionStateExecutor(sfName)) {
        }
 else {
          LOG.error("String_Node_Str",Thread.currentThread().getStackTrace()[1],sfName);
        }
        for (        SfServicePath sfServicePath : sfServicePathList) {
          String rspName=sfServicePath.getName();
          SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(rspName);
          rspList.add(rspName);
        }
        SfcProviderServicePathAPI.deleteRenderedServicePathsExecutor(rspList);
      }
    }
  }
  Map<InstanceIdentifier<?>,DataObject> dataUpdatedConfigurationObject=change.getUpdatedData();
  for (  Map.Entry<InstanceIdentifier<?>,DataObject> entry : dataUpdatedConfigurationObject.entrySet()) {
    if ((entry.getValue() instanceof ServiceFunction) && (!(dataCreatedObject.containsKey(entry.getKey())))) {
      DataObject dataObject=dataOriginalDataObject.get(entry.getKey());
      ServiceFunction originalServiceFunction=(ServiceFunction)dataObject;
      Object[] serviceFunctionObj={originalServiceFunction};
      Class[] serviceFunctionClass={ServiceFunction.class};
      ServiceFunction updatedServiceFunction=(ServiceFunction)entry.getValue();
      if (!updatedServiceFunction.getType().equals(originalServiceFunction.getType())) {
        Future future=odlSfc.executor.submit(SfcProviderServiceTypeAPI.getDeleteServiceFunctionFromServiceType(serviceFunctionObj,serviceFunctionClass));
        try {
          LOG.debug("String_Node_Str",future.get());
        }
 catch (        InterruptedException e) {
          LOG.warn("String_Node_Str",e);
        }
catch (        ExecutionException e) {
          LOG.warn("String_Node_Str",e);
        }
        serviceFunctionObj[0]=updatedServiceFunction;
        serviceFunctionClass[0]=ServiceFunction.class;
        odlSfc.executor.submit(SfcProviderServiceTypeAPI.getCreateServiceFunctionTypeEntry(serviceFunctionObj,serviceFunctionClass));
      }
      String sfName=originalServiceFunction.getName();
      List<SfServicePath> sfServicePathList=SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor(sfName);
      List<String> rspList=new ArrayList<>();
      if ((sfServicePathList != null) && (!sfServicePathList.isEmpty())) {
        if (SfcProviderServiceFunctionAPI.deleteServiceFunctionStateExecutor(sfName)) {
        }
 else {
          LOG.error("String_Node_Str",Thread.currentThread().getStackTrace()[1],sfName);
        }
        for (        SfServicePath sfServicePath : sfServicePathList) {
          String rspName=sfServicePath.getName();
          SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(rspName);
          rspList.add(rspName);
        }
        SfcProviderServicePathAPI.deleteRenderedServicePathsExecutor(rspList);
      }
    }
  }
  odlSfc.releaseLock();
  printTraceStop(LOG);
}

Fixed version (ground truth):
/** 
 * This method is called whenever there is change in a SF. Before doing any changes it takes a global lock in order to ensure it is the only writer.
 * @param change
 */
@Override public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>,DataObject> change){
  printTraceStart(LOG);
  odlSfc.getLock();
  Map<InstanceIdentifier<?>,DataObject> dataOriginalDataObject=change.getOriginalData();
  for (  Map.Entry<InstanceIdentifier<?>,DataObject> entry : dataOriginalDataObject.entrySet()) {
    if (entry.getValue() instanceof ServiceFunction) {
      ServiceFunction originalServiceFunction=(ServiceFunction)entry.getValue();
      LOG.debug("String_Node_Str",originalServiceFunction.getType(),originalServiceFunction.getName());
    }
  }
  Map<InstanceIdentifier<?>,DataObject> dataCreatedObject=change.getCreatedData();
  for (  Map.Entry<InstanceIdentifier<?>,DataObject> entry : dataCreatedObject.entrySet()) {
    if (entry.getValue() instanceof ServiceFunction) {
      ServiceFunction createdServiceFunction=(ServiceFunction)entry.getValue();
      Object[] serviceTypeObj={createdServiceFunction};
      Class[] serviceTypeClass={ServiceFunction.class};
      Future future=odlSfc.getExecutor().submit(SfcProviderServiceTypeAPI.getCreateServiceFunctionTypeEntry(serviceTypeObj,serviceTypeClass));
      try {
        LOG.debug("String_Node_Str",future.get());
      }
 catch (      InterruptedException e) {
        LOG.warn("String_Node_Str",e);
      }
catch (      ExecutionException e) {
        LOG.warn("String_Node_Str",e);
      }
      LOG.debug("String_Node_Str",createdServiceFunction.getType(),createdServiceFunction.getName());
    }
  }
  Set<InstanceIdentifier<?>> dataRemovedConfigurationIID=change.getRemovedPaths();
  for (  InstanceIdentifier instanceIdentifier : dataRemovedConfigurationIID) {
    DataObject dataObject=dataOriginalDataObject.get(instanceIdentifier);
    if (dataObject instanceof ServiceFunction) {
      ServiceFunction originalServiceFunction=(ServiceFunction)dataObject;
      Object[] serviceFunctionObj={originalServiceFunction};
      Class[] serviceFunctionClass={ServiceFunction.class};
      Future future=odlSfc.getExecutor().submit(SfcProviderServiceTypeAPI.getDeleteServiceFunctionFromServiceType(serviceFunctionObj,serviceFunctionClass));
      try {
        LOG.debug("String_Node_Str",future.get());
      }
 catch (      InterruptedException e) {
        LOG.warn("String_Node_Str",e);
      }
catch (      ExecutionException e) {
        LOG.warn("String_Node_Str",e);
      }
      String sfName=originalServiceFunction.getName();
      List<SfServicePath> sfServicePathList=SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor(sfName);
      List<String> rspList=new ArrayList<>();
      if ((sfServicePathList != null) && (!sfServicePathList.isEmpty())) {
        if (SfcProviderServiceFunctionAPI.deleteServiceFunctionStateExecutor(sfName)) {
        }
 else {
          LOG.error("String_Node_Str",Thread.currentThread().getStackTrace()[1],sfName);
        }
        for (        SfServicePath sfServicePath : sfServicePathList) {
          String rspName=sfServicePath.getName();
          SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(rspName);
          rspList.add(rspName);
        }
        SfcProviderServicePathAPI.deleteRenderedServicePathsExecutor(rspList);
      }
    }
  }
  Map<InstanceIdentifier<?>,DataObject> dataUpdatedConfigurationObject=change.getUpdatedData();
  for (  Map.Entry<InstanceIdentifier<?>,DataObject> entry : dataUpdatedConfigurationObject.entrySet()) {
    if ((entry.getValue() instanceof ServiceFunction) && (!(dataCreatedObject.containsKey(entry.getKey())))) {
      DataObject dataObject=dataOriginalDataObject.get(entry.getKey());
      ServiceFunction originalServiceFunction=(ServiceFunction)dataObject;
      Object[] serviceFunctionObj={originalServiceFunction};
      Class[] serviceFunctionClass={ServiceFunction.class};
      ServiceFunction updatedServiceFunction=(ServiceFunction)entry.getValue();
      if (!updatedServiceFunction.getType().equals(originalServiceFunction.getType())) {
        Future future=odlSfc.getExecutor().submit(SfcProviderServiceTypeAPI.getDeleteServiceFunctionFromServiceType(serviceFunctionObj,serviceFunctionClass));
        try {
          LOG.debug("String_Node_Str",future.get());
        }
 catch (        InterruptedException e) {
          LOG.warn("String_Node_Str",e);
        }
catch (        ExecutionException e) {
          LOG.warn("String_Node_Str",e);
        }
        serviceFunctionObj[0]=updatedServiceFunction;
        serviceFunctionClass[0]=ServiceFunction.class;
        odlSfc.getExecutor().submit(SfcProviderServiceTypeAPI.getCreateServiceFunctionTypeEntry(serviceFunctionObj,serviceFunctionClass));
      }
      String sfName=originalServiceFunction.getName();
      List<SfServicePath> sfServicePathList=SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor(sfName);
      List<String> rspList=new ArrayList<>();
      if ((sfServicePathList != null) && (!sfServicePathList.isEmpty())) {
        if (SfcProviderServiceFunctionAPI.deleteServiceFunctionStateExecutor(sfName)) {
        }
 else {
          LOG.error("String_Node_Str",Thread.currentThread().getStackTrace()[1],sfName);
        }
        for (        SfServicePath sfServicePath : sfServicePathList) {
          String rspName=sfServicePath.getName();
          SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(rspName);
          rspList.add(rspName);
        }
        SfcProviderServicePathAPI.deleteRenderedServicePathsExecutor(rspList);
      }
    }
  }
  odlSfc.releaseLock();
  printTraceStop(LOG);
}