Program: 114793
Project: 114793
Buggy source:
/** 
 * This method is used to migrate synapse files This changes the synapse api and add the new handlers
 */
private void synapseAPIMigration(){
  String repository=CarbonUtils.getCarbonRepository();
  String tenantRepository=CarbonUtils.getCarbonTenantsDirPath();
  for (  Tenant tenant : getTenantsArray()) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + tenant.getId() + '('+ tenant.getDomain()+ ')');
    }
    String apiFilePath;
    if (tenant.getId() != MultitenantConstants.SUPER_TENANT_ID) {
      apiFilePath=tenantRepository + '/' + tenant.getId()+ "String_Node_Str";
    }
 else {
      apiFilePath=repository + "String_Node_Str";
    }
    File APIFiles=new File(apiFilePath);
    File[] synapseFiles=APIFiles.listFiles();
    if (synapseFiles == null) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + apiFilePath + "String_Node_Str"+ tenant.getId()+ '('+ tenant.getDomain()+ ')');
      }
      continue;
    }
    for (    File synapseFile : synapseFiles) {
      DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
      docFactory.setNamespaceAware(true);
      try {
        docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,true);
        DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
        Document doc=docBuilder.parse(synapseFile);
        doc.getDocumentElement().normalize();
        Element rootElement=doc.getDocumentElement();
        if (Constants.SYNAPSE_API_ROOT_ELEMENT.equals(rootElement.getNodeName()) && rootElement.hasAttribute(Constants.SYNAPSE_API_ATTRIBUTE_VERSION)) {
          ResourceUtil.updateSynapseAPI(doc,synapseFile);
        }
      }
 catch (      ParserConfigurationException e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
catch (      SAXException e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
catch (      IOException e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
catch (      APIMigrationException e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
    }
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + tenant.getId() + '('+ tenant.getDomain()+ ')');
    }
  }
}

Fixed version (ground truth):
/** 
 * This method is used to migrate synapse files This changes the synapse api and add the new handlers
 */
private void synapseAPIMigration(){
  String repository=CarbonUtils.getCarbonRepository();
  String tenantRepository=CarbonUtils.getCarbonTenantsDirPath();
  for (  Tenant tenant : getTenantsArray()) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + tenant.getId() + '('+ tenant.getDomain()+ ')');
    }
    String apiFilePath;
    if (tenant.getId() != MultitenantConstants.SUPER_TENANT_ID) {
      apiFilePath=tenantRepository + '/' + tenant.getId()+ "String_Node_Str";
    }
 else {
      apiFilePath=repository + "String_Node_Str";
    }
    File APIFiles=new File(apiFilePath);
    File[] synapseFiles=APIFiles.listFiles();
    if (synapseFiles == null) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + apiFilePath + "String_Node_Str"+ tenant.getId()+ '('+ tenant.getDomain()+ ')');
      }
      continue;
    }
    for (    File synapseFile : synapseFiles) {
      DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
      docFactory.setNamespaceAware(true);
      try {
        docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,true);
        DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
        Document doc=docBuilder.parse(synapseFile);
        doc.getDocumentElement().normalize();
        Element rootElement=doc.getDocumentElement();
        if (Constants.SYNAPSE_API_ROOT_ELEMENT.equals(rootElement.getNodeName()) && rootElement.hasAttribute(Constants.SYNAPSE_API_ATTRIBUTE_VERSION)) {
          ResourceUtil.updateSynapseAPI(doc,synapseFile);
        }
      }
 catch (      ParserConfigurationException e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
catch (      SAXException e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
catch (      IOException e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
catch (      APIMigrationException e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
catch (      Exception e) {
        log.error("String_Node_Str" + synapseFile.getAbsolutePath(),e);
      }
    }
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + tenant.getId() + '('+ tenant.getDomain()+ ')');
    }
  }
}