Program: 127354
Project: 127354
Buggy source:
/** 
 * wzhang Comment method "addDefaultTableForSpecifiedDataPackage". this function only for add metadataTable.
 * @param dbconn
 * @param dbtable
 * @throws SQLException
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @throws ClassNotFoundException
 */
public static void addDefaultTableForSpecifiedDataPackage(DatabaseConnection dbconn,MetadataTable dbtable) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
  IMetadataConnection imetadataConnection=ConvertionHelper.convert(dbconn);
  String schema=imetadataConnection.getSchema();
  String catalog=imetadataConnection.getDatabase();
  String databaseType=imetadataConnection.getDbType();
  EDatabaseTypeName currentType=EDatabaseTypeName.getTypeFromDbType(databaseType);
  EDatabaseSchemaOrCatalogMapping curCatalog=currentType.getCatalogMappingField();
  EDatabaseSchemaOrCatalogMapping curSchema=currentType.getSchemaMappingField();
  if (curCatalog != null && curSchema != null) {
switch (curCatalog) {
case Login:
      catalog=imetadataConnection.getUsername();
    break;
case None:
  catalog="String_Node_Str";
break;
}
switch (curSchema) {
case Login:
schema=imetadataConnection.getUsername();
break;
case Schema:
schema=imetadataConnection.getSchema();
break;
case None:
schema="String_Node_Str";
break;
case Default_Name:
schema=dbconn.getName();
break;
}
}
boolean isAccess=EDatabaseTypeName.ACCESS.getDisplayName().equals(imetadataConnection.getDbType());
if (!isAccess) {
schema=ExtractMetaDataUtils.getMeataConnectionSchema(imetadataConnection);
}
boolean isOlap=ExtractMetaDataUtils.isOLAPConnection(dbconn);
if (isOlap) {
List<Catalog> catalogs=ConnectionHelper.getCatalogs(dbconn);
if (!catalogs.isEmpty()) {
Catalog c=catalogs.get(0);
catalog=c.getName();
if (!CatalogHelper.getSchemas(c).isEmpty()) {
Schema s=CatalogHelper.getSchemas(c).get(0);
schema=s.getName();
}
}
}
addTableForTemCatalogOrSchema(catalog,schema,dbconn,dbtable,imetadataConnection);
}

Fixed version (ground truth):
/** 
 * wzhang Comment method "addDefaultTableForSpecifiedDataPackage". this function only for add metadataTable.
 * @param dbconn
 * @param dbtable
 * @throws SQLException
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @throws ClassNotFoundException
 */
public static void addDefaultTableForSpecifiedDataPackage(DatabaseConnection dbconn,MetadataTable dbtable) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  IMetadataConnection imetadataConnection=ConvertionHelper.convert(dbconn);
  String schema=imetadataConnection.getSchema();
  String catalog=imetadataConnection.getDatabase();
  String databaseType=imetadataConnection.getDbType();
  EDatabaseTypeName currentType=EDatabaseTypeName.getTypeFromDbType(databaseType);
  EDatabaseSchemaOrCatalogMapping curCatalog=currentType.getCatalogMappingField();
  EDatabaseSchemaOrCatalogMapping curSchema=currentType.getSchemaMappingField();
  if (curCatalog != null && curSchema != null) {
switch (curCatalog) {
case Login:
      catalog=imetadataConnection.getUsername();
    break;
case None:
  catalog="String_Node_Str";
break;
}
switch (curSchema) {
case Login:
schema=imetadataConnection.getUsername();
break;
case Schema:
schema=imetadataConnection.getSchema();
break;
case None:
schema="String_Node_Str";
break;
case Default_Name:
schema=dbconn.getName();
break;
}
}
boolean isAccess=EDatabaseTypeName.ACCESS.getDisplayName().equals(imetadataConnection.getDbType());
if (!isAccess) {
schema=extractMeta.getMeataConnectionSchema(imetadataConnection);
}
boolean isOlap=extractMeta.isOLAPConnection(dbconn);
if (isOlap) {
List<Catalog> catalogs=ConnectionHelper.getCatalogs(dbconn);
if (!catalogs.isEmpty()) {
Catalog c=catalogs.get(0);
catalog=c.getName();
if (!CatalogHelper.getSchemas(c).isEmpty()) {
Schema s=CatalogHelper.getSchemas(c).get(0);
schema=s.getName();
}
}
}
addTableForTemCatalogOrSchema(catalog,schema,dbconn,dbtable,imetadataConnection);
}