Program: 126950
Project: 126950
Buggy source:
/** 
 * DOC ggu Comment method "returnMetadataColumnsFormTable".
 * @param metadataConnection
 * @param tableLabel
 * @param dontCreateClose
 * @return
 * @deprecated because still use it
 */
@Deprecated public synchronized List<TdColumn> returnMetadataColumnsFormTable(IMetadataConnection metadataConnection,String tableLabel,boolean... dontCreateClose){
  List<TdColumn> metadataColumns=new ArrayList<TdColumn>();
  boolean needCreateAndClose=dontCreateClose.length == 0 || !dontCreateClose[0];
  DriverShim wapperDriver=null;
  String dbType="String_Node_Str";
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  try {
    dbType=metadataConnection.getDbType();
    boolean isHive=EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType);
    if (!isHive && (needCreateAndClose || extractMeta.getConn() == null || extractMeta.getConn().isClosed())) {
      List list=extractMeta.getConnection(metadataConnection.getDbType(),metadataConnection.getUrl(),metadataConnection.getUsername(),metadataConnection.getPassword(),metadataConnection.getDatabase(),metadataConnection.getSchema(),metadataConnection.getDriverClass(),metadataConnection.getDriverJarPath(),metadataConnection.getDbVersionString(),metadataConnection.getAdditionalParams());
      if (list != null && list.size() > 0) {
        for (int i=0; i < list.size(); i++) {
          if (list.get(i) instanceof DriverShim) {
            wapperDriver=(DriverShim)list.get(i);
          }
        }
      }
    }
    DatabaseMetaData dbMetaData=null;
    if (isHive) {
      dbMetaData=HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnection);
    }
 else {
      dbMetaData=extractMeta.getDatabaseMetaData(extractMeta.getConn(),dbType,metadataConnection.isSqlMode(),metadataConnection.getDatabase());
    }
    tableLabel=checkTableLabel(tableLabel);
    List<String> cataAndShema=getTableCatalogAndSchema((DatabaseConnection)metadataConnection.getCurrentConnection(),tableLabel);
    metadataColumns=extractColumns(dbMetaData,metadataConnection,dbType,cataAndShema.get(0),cataAndShema.get(1),tableLabel);
  }
 catch (  Exception e) {
    log.error(e.toString());
    throw new RuntimeException(e);
  }
 finally {
    if (needCreateAndClose) {
      ConnectionUtils.closeConnection(extractMeta.getConn());
    }
  }
  return metadataColumns;
}

Fixed version (ground truth):
/** 
 * DOC ggu Comment method "returnMetadataColumnsFormTable".
 * @param metadataConnection
 * @param tableLabel
 * @param dontCreateClose
 * @return
 * @deprecated because still use it
 */
@Deprecated public synchronized List<TdColumn> returnMetadataColumnsFormTable(IMetadataConnection metadataConnection,String tableLabel,boolean... dontCreateClose){
  List<TdColumn> metadataColumns=new ArrayList<TdColumn>();
  boolean needCreateAndClose=dontCreateClose.length == 0 || !dontCreateClose[0];
  DriverShim wapperDriver=null;
  String dbType="String_Node_Str";
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  try {
    dbType=metadataConnection.getDbType();
    boolean isHive=EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType);
    if (!isHive && (needCreateAndClose || extractMeta.getConn() == null || extractMeta.getConn().isClosed())) {
      List list=extractMeta.getConnection(metadataConnection.getDbType(),metadataConnection.getUrl(),metadataConnection.getUsername(),metadataConnection.getPassword(),metadataConnection.getDatabase(),metadataConnection.getSchema(),metadataConnection.getDriverClass(),metadataConnection.getDriverJarPath(),metadataConnection.getDbVersionString(),metadataConnection.getAdditionalParams());
      if (list != null && list.size() > 0) {
        for (int i=0; i < list.size(); i++) {
          if (list.get(i) instanceof DriverShim) {
            wapperDriver=(DriverShim)list.get(i);
          }
        }
      }
    }
    DatabaseMetaData dbMetaData=null;
    if (isHive) {
      dbMetaData=HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnection);
    }
 else {
      dbMetaData=extractMeta.getDatabaseMetaData(extractMeta.getConn(),dbType,metadataConnection.isSqlMode(),metadataConnection.getDatabase());
    }
    tableLabel=checkTableLabel(tableLabel);
    List<String> cataAndShema=getTableCatalogAndSchema((DatabaseConnection)metadataConnection.getCurrentConnection(),tableLabel);
    metadataColumns=extractColumns(dbMetaData,metadataConnection,dbType,cataAndShema.get(0),cataAndShema.get(1),tableLabel);
  }
 catch (  Exception e) {
    log.error(e.toString());
    throw new RuntimeException(e);
  }
 finally {
    if (needCreateAndClose && extractMeta.getConn() != null) {
      ConnectionUtils.closeConnection(extractMeta.getConn());
    }
  }
  return metadataColumns;
}