Program: 102938
Project: 102938
Buggy source:
/** 
 * Initializes the storage manager and makes it do initial load and parsing of the contact list file.
 * @param bc a reference to the currently valid OSGI <tt>BundleContext</tt>
 * @param mclServImpl a reference to the currently valid instance of the<tt>MetaContactListServiceImpl</tt> that we could use to pass parsed contacts and contact groups.
 * @throws IOException if the contact list file specified file does notexist and could not be created.
 * @throws XMLException if there is a problem with the file syntax.
 */
void start(BundleContext bc,MetaContactListServiceImpl mclServImpl) throws IOException, XMLException {
  bundleContext=bc;
  ServiceReference faServiceReference=bundleContext.getServiceReference(FileAccessService.class.getName());
  faService=(FileAccessService)bundleContext.getService(faServiceReference);
  ServiceReference confServiceRefs=bundleContext.getServiceReference(ConfigurationService.class.getName());
  ConfigurationService configurationService=(ConfigurationService)bundleContext.getService(confServiceRefs);
  String fileName=configurationService.getString(FILE_NAME_PROPERTY);
  if (fileName == null) {
    fileName=System.getProperty(FILE_NAME_PROPERTY);
    if (fileName == null)     fileName=DEFAULT_FILE_NAME;
  }
  try {
    contactlistFile=faService.getPrivatePersistentFile(fileName,FileCategory.PROFILE);
    if (!contactlistFile.exists() && !contactlistFile.createNewFile())     throw new IOException("String_Node_Str" + contactlistFile.getAbsolutePath());
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + "String_Node_Str" + fileName + "String_Node_Str"+ ex.getMessage());
  }
  multiTenantMode=configurationService.getBoolean(MULTI_TENANT_MODE_PROP,multiTenantMode);
  try {
    contactlistTrans=faService.createFailSafeTransaction(this.contactlistFile);
    contactlistTrans.restoreFile();
  }
 catch (  NullPointerException e) {
    logger.error("String_Node_Str",e);
  }
catch (  IllegalStateException e) {
    logger.error("String_Node_Str",e);
  }
  try {
    DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
    DocumentBuilder builder=factory.newDocumentBuilder();
    if (contactlistFile.length() == 0) {
      contactListDocument=builder.newDocument();
      initVirginDocument(mclServImpl,contactListDocument);
      storeContactList0();
    }
 else {
      try {
        contactListDocument=builder.parse(contactlistFile);
      }
 catch (      Throwable ex) {
        logger.error("String_Node_Str",ex);
        logger.error("String_Node_Str");
        contactlistFile.delete();
        contactlistFile.createNewFile();
        contactListDocument=builder.newDocument();
        initVirginDocument(mclServImpl,contactListDocument);
        storeContactList0();
      }
    }
  }
 catch (  ParserConfigurationException ex) {
    logger.error("String_Node_Str",ex);
  }
  mclServImpl.addMetaContactListListener(this);
  this.mclServiceImpl=mclServImpl;
  started=true;
  this.launchStorageThread();
}

Fixed version (ground truth):
/** 
 * Initializes the storage manager and makes it do initial load and parsing of the contact list file.
 * @param bc a reference to the currently valid OSGI <tt>BundleContext</tt>
 * @param mclServImpl a reference to the currently valid instance of the<tt>MetaContactListServiceImpl</tt> that we could use to pass parsed contacts and contact groups.
 * @throws IOException if the contact list file specified file does notexist and could not be created.
 * @throws XMLException if there is a problem with the file syntax.
 */
void start(BundleContext bc,MetaContactListServiceImpl mclServImpl) throws IOException, XMLException {
  bundleContext=bc;
  faService=ServiceUtils.getService(bundleContext,FileAccessService.class);
  ConfigurationService configurationService=ServiceUtils.getService(bundleContext,ConfigurationService.class);
  String fileName=configurationService.getString(FILE_NAME_PROPERTY);
  if (fileName == null) {
    fileName=System.getProperty(FILE_NAME_PROPERTY);
    if (fileName == null)     fileName=DEFAULT_FILE_NAME;
  }
  try {
    contactlistFile=faService.getPrivatePersistentFile(fileName,FileCategory.PROFILE);
    if (!contactlistFile.exists() && !contactlistFile.createNewFile()) {
      throw new IOException("String_Node_Str" + contactlistFile.getAbsolutePath());
    }
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + "String_Node_Str" + fileName + "String_Node_Str"+ ex.getMessage());
  }
  multiTenantMode=configurationService.getBoolean(MULTI_TENANT_MODE_PROP,multiTenantMode);
  try {
    contactlistTrans=faService.createFailSafeTransaction(this.contactlistFile);
    contactlistTrans.restoreFile();
  }
 catch (  NullPointerException e) {
    logger.error("String_Node_Str",e);
  }
catch (  IllegalStateException e) {
    logger.error("String_Node_Str",e);
  }
  try {
    DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
    DocumentBuilder builder=factory.newDocumentBuilder();
    if (contactlistFile.length() == 0) {
      contactListDocument=builder.newDocument();
      initVirginDocument(mclServImpl,contactListDocument);
      storeContactList0();
    }
 else {
      try {
        contactListDocument=builder.parse(contactlistFile);
      }
 catch (      Throwable ex) {
        logger.error("String_Node_Str",ex);
        logger.error("String_Node_Str");
        contactlistFile.delete();
        contactlistFile.createNewFile();
        contactListDocument=builder.newDocument();
        initVirginDocument(mclServImpl,contactListDocument);
        storeContactList0();
      }
    }
  }
 catch (  ParserConfigurationException ex) {
    logger.error("String_Node_Str",ex);
  }
  mclServImpl.addMetaContactListListener(this);
  this.mclServiceImpl=mclServImpl;
  started=true;
  this.launchStorageThread();
}