Program: 127373
Project: 127373
Buggy source:
private static List<TdTable> loadTables(Connection dataPloadTablesrovider,Catalog catalog,Schema schema,String tablePattern) throws Exception {
  List<TdTable> tables=new ArrayList<TdTable>();
  TypedReturnCode<java.sql.Connection> rcConn=MetadataConnectionUtils.checkConnection((DatabaseConnection)dataPloadTablesrovider);
  if (!rcConn.isOk()) {
    log.error(rcConn.getMessage());
    throw new Exception(rcConn.getMessage());
  }
  java.sql.Connection connection=rcConn.getObject();
  String[] tableType=new String[]{TableType.TABLE.toString()};
  try {
    DatabaseMetaData dm=ExtractMetaDataUtils.getDatabaseMetaData(connection,(DatabaseConnection)dataPloadTablesrovider,false);
    if (schema != null) {
      if (PackageHelper.getTables(schema).size() == 0) {
        tables=MetadataFillFactory.getDBInstance().fillTables(schema,dm,null,tablePattern,tableType);
      }
 else {
        MetadataFillFactory.getDBInstance().setLinked(false);
        tables=MetadataFillFactory.getDBInstance().fillTables(schema,dm,null,tablePattern,tableType);
        MetadataFillFactory.getDBInstance().setLinked(true);
      }
    }
 else {
      if (PackageHelper.getTables(catalog).size() == 0) {
        tables=MetadataFillFactory.getDBInstance().fillTables(catalog,dm,null,tablePattern,tableType);
      }
 else {
        MetadataFillFactory.getDBInstance().setLinked(false);
        tables=MetadataFillFactory.getDBInstance().fillTables(catalog,dm,null,tablePattern,tableType);
        MetadataFillFactory.getDBInstance().setLinked(true);
      }
    }
  }
  finally {
    ConnectionUtils.closeConnection(connection);
  }
  return tables;
}

Fixed version (ground truth):
private static List<TdTable> loadTables(Connection dataPloadTablesrovider,Catalog catalog,Schema schema,String tablePattern) throws Exception {
  List<TdTable> tables=new ArrayList<TdTable>();
  TypedReturnCode<java.sql.Connection> rcConn=MetadataConnectionUtils.checkConnection((DatabaseConnection)dataPloadTablesrovider);
  if (!rcConn.isOk()) {
    log.error(rcConn.getMessage());
    throw new Exception(rcConn.getMessage());
  }
  java.sql.Connection connection=rcConn.getObject();
  try {
    DatabaseMetaData dm=ExtractMetaDataUtils.getDatabaseMetaData(connection,(DatabaseConnection)dataPloadTablesrovider,false);
    if (schema != null) {
      if (PackageHelper.getTables(schema).size() == 0) {
        tables=MetadataFillFactory.getDBInstance().fillTables(schema,dm,null,tablePattern,TABLE_TYPES);
      }
 else {
        MetadataFillFactory.getDBInstance().setLinked(false);
        tables=MetadataFillFactory.getDBInstance().fillTables(schema,dm,null,tablePattern,TABLE_TYPES);
        MetadataFillFactory.getDBInstance().setLinked(true);
      }
    }
 else {
      if (PackageHelper.getTables(catalog).size() == 0) {
        tables=MetadataFillFactory.getDBInstance().fillTables(catalog,dm,null,tablePattern,TABLE_TYPES);
      }
 else {
        MetadataFillFactory.getDBInstance().setLinked(false);
        tables=MetadataFillFactory.getDBInstance().fillTables(catalog,dm,null,tablePattern,TABLE_TYPES);
        MetadataFillFactory.getDBInstance().setLinked(true);
      }
    }
  }
  finally {
    ConnectionUtils.closeConnection(connection);
  }
  return tables;
}