Program: 127057
Project: 127057
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) {
    try {
      while (schemaRs.next()) {
        String schemaName=null;
        String catalogName=null;
        try {
          schemaName=schemaRs.getString(MetaDataConstants.TABLE_SCHEM.name());
          if (!(MetadataConnectionUtils.isPostgresql(dbJDBCMetadata) || MetadataConnectionUtils.isSybase(dbJDBCMetadata))) {
            catalogName=schemaRs.getString(MetaDataConstants.TABLE_CATALOG.name());
          }
          if (MetadataConnectionUtils.isMssql(dbJDBCMetadata) && dbJDBCMetadata.getDatabaseMajorVersion() > 8 && dbJDBCMetadata.getDriverMajorVersion() > 1) {
            if (catalogName != null && catalogName != schemaName) {
              schemaName=catalogName;
            }
          }
          if (schemaName == null || !MetadataConnectionUtils.isMssql(dbJDBCMetadata.getConnection()) && catalogName != null && !catalogName.equals(catalog.getName())) {
            continue;
          }
        }
 catch (        Exception e) {
        }
        if (!schemaNameCacheTmp.contains(schemaName) && !MetadataConnectionUtils.isMysql(dbJDBCMetadata)) {
          if (!isNullUiSchema(dbConn) && dbConn != null) {
            String uiSchemaOnConnWizard=((DatabaseConnection)dbConn).getUiSchema();
            Schema schema=SchemaHelper.createSchema(TalendCWMService.getReadableName(dbConn,uiSchemaOnConnWizard));
            schemaList.add(schema);
            break;
          }
 else           if (isCreateElement(schemaFilter,schemaName)) {
            Schema schema=SchemaHelper.createSchema(schemaName);
            schemaList.add(schema);
            schemaNameCacheTmp.add(schemaName);
          }
        }
      }
      schemaRs.close();
    }
 catch (    Exception e) {
      if (log.isDebugEnabled()) {
        log.debug(e,e);
      }
    }
  }
  return schemaList;
}

Fixed version (ground truth):
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) {
    try {
      while (schemaRs.next()) {
        String schemaName=getSchemaName(schemaRs,dbJDBCMetadata,catalog);
        if (schemaName == null) {
          continue;
        }
        if (!schemaNameCacheTmp.contains(schemaName) && !MetadataConnectionUtils.isMysql(dbJDBCMetadata)) {
          if (!isNullUiSchema(dbConn) && dbConn != null) {
            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);
          }
        }
      }
      schemaRs.close();
    }
 catch (    Exception e) {
      if (log.isDebugEnabled()) {
        log.debug(e,e);
      }
    }
  }
  return schemaList;
}