Program: 138818
Project: 138818
Buggy source:
/** 
 * Method "createDataProvider" create the data provider, the catalogs and the schemas. The created data provider and its related Catalog and Schemas are stored in the DBConnect class. In order to finally serialize them in a file, the method   {@link DBConnect#saveInFiles()} must be called.
 * @param connector the helper for building CWM objects from a connection
 * @param folderProvider contains the path where the file will be stored.
 * @return the data provider
 * @throws SQLException
 */
public static Connection createDataProvider(DBConnect connector) throws SQLException {
  checkConnection(connector);
  Connection dataProvider=getTdDataProvider(connector);
  if (connector.retrieveDeployedSystemInformations()) {
    TdSoftwareSystem softwareSystem=connector.getSoftwareSystem();
    if (softwareSystem != null) {
      ConnectionHelper.setSoftwareSystem(dataProvider,softwareSystem);
    }
  }
  Collection<Catalog> catalogs=getCatalogs(connector);
  Collection<Schema> schemata=getSchemata(connector);
  boolean allAdded=false;
  if (catalogs.isEmpty()) {
    allAdded=ConnectionHelper.addSchemas(schemata,dataProvider);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + schemata.size() + "String_Node_Str"+ allAdded);
    }
  }
 else {
    allAdded=ConnectionHelper.addCatalogs(catalogs,dataProvider);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + catalogs.size() + "String_Node_Str"+ allAdded);
    }
  }
  if (log.isInfoEnabled()) {
    log.info(catalogs.size() + "String_Node_Str");
    log.info(schemata.size() + "String_Node_Str");
  }
  if (log.isDebugEnabled()) {
    printInformations(catalogs,schemata);
  }
  String dbType=connector.getDbConnectionParameter().getSqlTypeName();
  String product=EDatabaseTypeName.getTypeFromDisplayName(dbType).getProduct();
  String mapping=MetadataTalendType.getDefaultDbmsFromProduct(product).getId();
  if (dataProvider instanceof DatabaseConnection) {
    ((DatabaseConnection)dataProvider).setProductId(product);
    ((DatabaseConnection)dataProvider).setDbmsId(mapping);
  }
  return dataProvider;
}

Fixed version (ground truth):
/** 
 * Method "createDataProvider" create the data provider, the catalogs and the schemas. The created data provider and its related Catalog and Schemas are stored in the DBConnect class. In order to finally serialize them in a file, the method   {@link DBConnect#saveInFiles()} must be called.
 * @param connector the helper for building CWM objects from a connection
 * @param folderProvider contains the path where the file will be stored.
 * @return the data provider
 * @throws SQLException
 */
public static Connection createDataProvider(DBConnect connector) throws SQLException {
  checkConnection(connector);
  Connection dataProvider=getTdDataProvider(connector);
  if (connector.retrieveDeployedSystemInformations()) {
    TdSoftwareSystem softwareSystem=connector.getSoftwareSystem();
    if (softwareSystem != null) {
      ConnectionHelper.setSoftwareSystem(dataProvider,softwareSystem);
    }
  }
  Collection<Catalog> catalogs=getCatalogs(connector);
  Collection<Schema> schemata=getSchemata(connector);
  boolean allAdded=false;
  if (catalogs.isEmpty()) {
    allAdded=ConnectionHelper.addSchemas(schemata,dataProvider);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + schemata.size() + "String_Node_Str"+ allAdded);
    }
  }
 else {
    allAdded=ConnectionHelper.addCatalogs(catalogs,dataProvider);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + catalogs.size() + "String_Node_Str"+ allAdded);
    }
  }
  if (log.isInfoEnabled()) {
    log.info(catalogs.size() + "String_Node_Str");
    log.info(schemata.size() + "String_Node_Str");
  }
  if (log.isDebugEnabled()) {
    printInformations(catalogs,schemata);
  }
  if (!ReponsitoryContextBridge.isDefautProject()) {
    String dbType=connector.getDbConnectionParameter().getSqlTypeName();
    String product=EDatabaseTypeName.getTypeFromDisplayName(dbType).getProduct();
    String mapping=MetadataTalendType.getDefaultDbmsFromProduct(product).getId();
    if (dataProvider instanceof DatabaseConnection) {
      ((DatabaseConnection)dataProvider).setProductId(product);
      ((DatabaseConnection)dataProvider).setDbmsId(mapping);
    }
  }
  return dataProvider;
}