Program: 127372
Project: 127372
Buggy source:
private static List<TdView> loadViews(Connection dataProvider,Catalog catalog,Schema schema,String viewPattern) throws Exception {
  List<TdView> views=new ArrayList<TdView>();
  TypedReturnCode<java.sql.Connection> rcConn=MetadataConnectionUtils.checkConnection((DatabaseConnection)dataProvider);
  if (!rcConn.isOk()) {
    log.error(rcConn.getMessage());
    throw new Exception(rcConn.getMessage());
  }
  java.sql.Connection connection=rcConn.getObject();
  DatabaseConnection databaseConnection=(DatabaseConnection)dataProvider;
  DatabaseMetaData dm=ExtractMetaDataUtils.getDatabaseMetaData(connection,databaseConnection,false);
  try {
    if (schema != null) {
      if (PackageHelper.getViews(schema).size() == 0) {
        views=MetadataFillFactory.getDBInstance().fillViews(schema,dm,null,viewPattern);
      }
 else {
        MetadataFillFactory.getDBInstance().setLinked(false);
        views=MetadataFillFactory.getDBInstance().fillViews(schema,dm,null,viewPattern);
        MetadataFillFactory.getDBInstance().setLinked(true);
      }
    }
 else {
      if (PackageHelper.getViews(catalog).size() == 0) {
        views=MetadataFillFactory.getDBInstance().fillViews(catalog,dm,null,viewPattern);
      }
 else {
        MetadataFillFactory.getDBInstance().setLinked(false);
        views=MetadataFillFactory.getDBInstance().fillViews(catalog,dm,null,viewPattern);
        MetadataFillFactory.getDBInstance().setLinked(true);
      }
    }
  }
  finally {
    ConnectionUtils.closeConnection(connection);
  }
  return views;
}

Fixed version (ground truth):
private static List<TdView> loadViews(Connection dataProvider,Catalog catalog,Schema schema,String viewPattern) throws Exception {
  List<TdView> views=new ArrayList<TdView>();
  TypedReturnCode<java.sql.Connection> rcConn=MetadataConnectionUtils.checkConnection((DatabaseConnection)dataProvider);
  if (!rcConn.isOk()) {
    log.error(rcConn.getMessage());
    throw new Exception(rcConn.getMessage());
  }
  java.sql.Connection connection=rcConn.getObject();
  DatabaseConnection databaseConnection=(DatabaseConnection)dataProvider;
  DatabaseMetaData dm=ExtractMetaDataUtils.getDatabaseMetaData(connection,databaseConnection,false);
  try {
    if (schema != null) {
      if (PackageHelper.getViews(schema).size() == 0) {
        views=MetadataFillFactory.getDBInstance().fillViews(schema,dm,null,viewPattern,VIEW_TYPES);
      }
 else {
        MetadataFillFactory.getDBInstance().setLinked(false);
        views=MetadataFillFactory.getDBInstance().fillViews(schema,dm,null,viewPattern,VIEW_TYPES);
        MetadataFillFactory.getDBInstance().setLinked(true);
      }
    }
 else {
      if (PackageHelper.getViews(catalog).size() == 0) {
        views=MetadataFillFactory.getDBInstance().fillViews(catalog,dm,null,viewPattern,VIEW_TYPES);
      }
 else {
        MetadataFillFactory.getDBInstance().setLinked(false);
        views=MetadataFillFactory.getDBInstance().fillViews(catalog,dm,null,viewPattern,VIEW_TYPES);
        MetadataFillFactory.getDBInstance().setLinked(true);
      }
    }
  }
  finally {
    ConnectionUtils.closeConnection(connection);
  }
  return views;
}