Program: 126741
Project: 126741
Buggy source:
public List<Schema> fillSchemaToCatalog(Connection dbConn,DatabaseMetaData dbJDBCMetadata,Catalog catalog,List<String> schemaFilter) throws Throwable {
  ResultSet schemaRs=null;
  try {
    if (dbJDBCMetadata.getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0)) {
      Method getSchemaMethod=dbJDBCMetadata.getClass().getMethod("String_Node_Str",String.class,String.class);
      schemaRs=(ResultSet)getSchemaMethod.invoke(dbJDBCMetadata,catalog.getName(),null);
    }
  }
 catch (  SecurityException e) {
  }
catch (  NoSuchMethodException e) {
  }
catch (  IllegalArgumentException e) {
  }
catch (  IllegalAccessException e) {
  }
catch (  InvocationTargetException e) {
    if (e.getTargetException().getClass().toString().equals("String_Node_Str")) {
      throw e.getTargetException();
    }
  }
catch (  SQLException e) {
    log.error(e,e);
  }
  if (schemaRs == null) {
    try {
      if (dbJDBCMetadata instanceof SybaseDatabaseMetaData) {
        schemaRs=((SybaseDatabaseMetaData)dbJDBCMetadata).getSchemas(catalog.getName(),null);
      }
 else       if (dbJDBCMetadata instanceof AS400DatabaseMetaData) {
        schemaRs=dbJDBCMetadata.getSchemas(catalog.getName(),null);
      }
 else {
        schemaRs=dbJDBCMetadata.getSchemas();
      }
    }
 catch (    SQLException e) {
      if (log.isDebugEnabled()) {
        log.debug(e,e);
      }
    }
  }
  List<String> schemaNameCacheTmp=new ArrayList<String>();
  List<Schema> schemaList=new ArrayList<Schema>();
  if (schemaRs == null) {
    log.error("String_Node_Str");
  }
 else {
    try {
      while (schemaRs.next()) {
        String schemaName=getSchemaName(schemaRs,dbJDBCMetadata,catalog);
        if (schemaName == null) {
          continue;
        }
        if (!schemaNameCacheTmp.contains(schemaName) && !MetadataConnectionUtils.isMysql(dbJDBCMetadata)) {
          if (dbConn != null && !isNullUiSchema(dbConn)) {
            Schema createByUiSchema=createSchemaByUiSchema((DatabaseConnection)dbConn);
            schemaList.add(createByUiSchema);
            break;
          }
 else           if (isCreateElement(schemaFilter,schemaName)) {
            Schema schema=SchemaHelper.createSchema(schemaName);
            schemaList.add(schema);
            schemaNameCacheTmp.add(schemaName);
          }
        }
      }
    }
 catch (    Exception e) {
      if (log.isDebugEnabled()) {
        log.debug(e,e);
      }
    }
 finally {
      schemaRs.close();
    }
  }
  return schemaList;
}

Fixed version (ground truth):
public List<Schema> fillSchemaToCatalog(DatabaseConnection dbConn,DatabaseMetaData dbJDBCMetadata,Catalog catalog,List<String> schemaFilter) throws Throwable {
  ResultSet schemaRs=null;
  try {
    if (dbJDBCMetadata.getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0)) {
      Method getSchemaMethod=dbJDBCMetadata.getClass().getMethod("String_Node_Str",String.class,String.class);
      schemaRs=(ResultSet)getSchemaMethod.invoke(dbJDBCMetadata,catalog.getName(),null);
    }
  }
 catch (  SecurityException e) {
  }
catch (  NoSuchMethodException e) {
  }
catch (  IllegalArgumentException e) {
  }
catch (  IllegalAccessException e) {
  }
catch (  InvocationTargetException e) {
    if (e.getTargetException().getClass().toString().equals("String_Node_Str")) {
      throw e.getTargetException();
    }
  }
catch (  SQLException e) {
    log.error(e,e);
  }
  if (schemaRs == null) {
    try {
      if (dbJDBCMetadata instanceof SybaseDatabaseMetaData) {
        schemaRs=((SybaseDatabaseMetaData)dbJDBCMetadata).getSchemas(catalog.getName(),null);
      }
 else       if (dbJDBCMetadata instanceof AS400DatabaseMetaData) {
        schemaRs=dbJDBCMetadata.getSchemas(catalog.getName(),null);
      }
 else {
        schemaRs=dbJDBCMetadata.getSchemas();
      }
    }
 catch (    SQLException e) {
      if (log.isDebugEnabled()) {
        log.debug(e,e);
      }
    }
  }
  List<String> schemaNameCacheTmp=new ArrayList<String>();
  List<Schema> schemaList=new ArrayList<Schema>();
  if (schemaRs == null) {
    log.error("String_Node_Str");
  }
 else {
    try {
      while (schemaRs.next()) {
        String schemaName=getSchemaName(schemaRs,dbJDBCMetadata,catalog);
        if (schemaName == null) {
          continue;
        }
        if (!schemaNameCacheTmp.contains(schemaName) && !MetadataConnectionUtils.isMysql(dbJDBCMetadata)) {
          if (dbConn != null && !isNullUiSchema(dbConn)) {
            Schema createByUiSchema=createSchemaByUiSchema(dbConn);
            schemaList.add(createByUiSchema);
            break;
          }
 else           if (isCreateElement(schemaFilter,schemaName)) {
            Schema schema=SchemaHelper.createSchema(schemaName);
            schemaList.add(schema);
            schemaNameCacheTmp.add(schemaName);
          }
        }
      }
    }
 catch (    Exception e) {
      if (log.isDebugEnabled()) {
        log.debug(e,e);
      }
    }
 finally {
      schemaRs.close();
    }
  }
  return schemaList;
}