Program: 138010
Project: 138010
Buggy source:
public static TypedReturnCode<Connection> getRefreshedDataProvider(Connection prevDataProvider){
  TypedReturnCode<Connection> returnProvider=new TypedReturnCode<Connection>();
  boolean mdm=ConnectionUtils.isMdmConnection(prevDataProvider);
  String urlString=JavaSqlFactory.getURL(prevDataProvider);
  String driverClassName=JavaSqlFactory.getDriverClass(prevDataProvider);
  Properties properties=new Properties();
  properties.setProperty(TaggedValueHelper.USER,JavaSqlFactory.getUsername(prevDataProvider));
  properties.setProperty(TaggedValueHelper.PASSWORD,JavaSqlFactory.getPassword(prevDataProvider));
  DBConnectionParameter connectionParameters=new DBConnectionParameter();
  connectionParameters.setName(prevDataProvider.getName());
  connectionParameters.setAuthor(MetadataHelper.getAuthor(prevDataProvider));
  connectionParameters.setDescription(MetadataHelper.getDescription(prevDataProvider));
  connectionParameters.setPurpose(MetadataHelper.getPurpose(prevDataProvider));
  connectionParameters.setStatus(MetadataHelper.getDevStatus(prevDataProvider));
  String dbType=ConnectionUtils.getDatabaseType(prevDataProvider);
  connectionParameters.setSqlTypeName(dbType);
  connectionParameters.setJdbcUrl(urlString);
  connectionParameters.setDriverClassName(driverClassName);
  connectionParameters.setParameters(properties);
  connectionParameters.setDbName(ConnectionUtils.getSID(prevDataProvider));
  connectionParameters.setRetrieveAllMetadata(ConnectionHelper.getRetrieveAllMetadata(prevDataProvider));
  if (prevDataProvider instanceof DatabaseConnection) {
    DatabaseConnection dbConn=(DatabaseConnection)prevDataProvider;
    String uiSchema=dbConn.getUiSchema();
    if (dbConn.isContextMode() && uiSchema != null) {
      uiSchema=ConnectionUtils.getOriginalConntextValue(dbConn,uiSchema);
    }
    connectionParameters.setFilterSchema(uiSchema);
  }
  IMetadataConnection metadataConnection=MetadataFillFactory.getMDMInstance().fillUIParams(ParameterUtil.toMap(connectionParameters));
  List<String> packageFilter=ConnectionUtils.getPackageFilter(connectionParameters);
  Connection conn=null;
  if (mdm) {
    conn=MetadataFillFactory.getMDMInstance().fillUIConnParams(metadataConnection,null);
    MetadataFillFactory.getMDMInstance().fillSchemas(conn,null,packageFilter);
  }
 else {
    TypedReturnCode<?> trc=(TypedReturnCode<?>)MetadataFillFactory.getDBInstance().checkConnection(metadataConnection);
    Object sqlConnObject=trc.getObject();
    DatabaseMetaData dbJDBCMetadata=null;
    if (trc.isOk() && sqlConnObject instanceof java.sql.Connection) {
      java.sql.Connection sqlConn=(java.sql.Connection)sqlConnObject;
      try {
        dbJDBCMetadata=ExtractMetaDataUtils.getConnectionMetadata(sqlConn);
      }
 catch (      SQLException e) {
        log.error(e,e);
      }
    }
    conn=MetadataFillFactory.getDBInstance().fillUIConnParams(metadataConnection,null);
    try {
      if (ConnectionUtils.isIngres(prevDataProvider) || ConnectionUtils.isInformix(prevDataProvider) || ConnectionUtils.isDB2(prevDataProvider)) {
        packageFilter=null;
      }
      if (ConnectionUtils.isDB2(prevDataProvider) && connectionParameters.getFilterSchema() != null && !connectionParameters.getFilterSchema().equals("String_Node_Str")) {
        if (packageFilter == null) {
          packageFilter=new ArrayList<String>();
        }
        packageFilter.add(connectionParameters.getFilterSchema());
      }
      MetadataFillFactory.getDBInstance().fillCatalogs(conn,dbJDBCMetadata,packageFilter);
      MetadataFillFactory.getDBInstance().fillSchemas(conn,dbJDBCMetadata,packageFilter);
    }
 catch (    SQLException e) {
      log.error(e);
    }
  }
  if (conn == null) {
    returnProvider.setOk(false);
  }
 else {
    returnProvider.setObject(conn);
  }
  return returnProvider;
}

Fixed version (ground truth):
public static TypedReturnCode<Connection> getRefreshedDataProvider(Connection prevDataProvider){
  TypedReturnCode<Connection> returnProvider=new TypedReturnCode<Connection>();
  boolean mdm=ConnectionUtils.isMdmConnection(prevDataProvider);
  String urlString=JavaSqlFactory.getURL(prevDataProvider);
  String driverClassName=JavaSqlFactory.getDriverClass(prevDataProvider);
  driverClassName=ConnectionUtils.getOriginalConntextValue(prevDataProvider,driverClassName);
  Properties properties=new Properties();
  properties.setProperty(TaggedValueHelper.USER,JavaSqlFactory.getUsername(prevDataProvider));
  properties.setProperty(TaggedValueHelper.PASSWORD,JavaSqlFactory.getPassword(prevDataProvider));
  DBConnectionParameter connectionParameters=new DBConnectionParameter();
  connectionParameters.setName(prevDataProvider.getName());
  connectionParameters.setAuthor(MetadataHelper.getAuthor(prevDataProvider));
  connectionParameters.setDescription(MetadataHelper.getDescription(prevDataProvider));
  connectionParameters.setPurpose(MetadataHelper.getPurpose(prevDataProvider));
  connectionParameters.setStatus(MetadataHelper.getDevStatus(prevDataProvider));
  String dbType=ConnectionUtils.getDatabaseType(prevDataProvider);
  connectionParameters.setSqlTypeName(dbType);
  connectionParameters.setJdbcUrl(urlString);
  connectionParameters.setDriverClassName(driverClassName);
  connectionParameters.setParameters(properties);
  connectionParameters.setDbName(ConnectionUtils.getSID(prevDataProvider));
  connectionParameters.setRetrieveAllMetadata(ConnectionHelper.getRetrieveAllMetadata(prevDataProvider));
  if (prevDataProvider instanceof DatabaseConnection) {
    DatabaseConnection dbConn=(DatabaseConnection)prevDataProvider;
    String uiSchema=dbConn.getUiSchema();
    String driverJarPath=dbConn.getDriverJarPath();
    if (dbConn.isContextMode() && uiSchema != null) {
      uiSchema=ConnectionUtils.getOriginalConntextValue(dbConn,uiSchema);
      driverJarPath=ConnectionUtils.getOriginalConntextValue(dbConn,driverJarPath);
    }
    connectionParameters.setDriverPath(driverJarPath);
    connectionParameters.setFilterSchema(uiSchema);
  }
  IMetadataConnection metadataConnection=null;
  List<String> packageFilter=ConnectionUtils.getPackageFilter(connectionParameters);
  Connection conn=null;
  if (mdm) {
    metadataConnection=MetadataFillFactory.getMDMInstance().fillUIParams(ParameterUtil.toMap(connectionParameters));
    conn=MetadataFillFactory.getMDMInstance().fillUIConnParams(metadataConnection,null);
    MetadataFillFactory.getMDMInstance().fillSchemas(conn,null,packageFilter);
  }
 else {
    metadataConnection=MetadataFillFactory.getMDMInstance().fillUIParams(ParameterUtil.toMap(connectionParameters));
    TypedReturnCode<?> trc=(TypedReturnCode<?>)MetadataFillFactory.getDBInstance().checkConnection(metadataConnection);
    Object sqlConnObject=trc.getObject();
    DatabaseMetaData dbJDBCMetadata=null;
    if (trc.isOk() && sqlConnObject instanceof java.sql.Connection) {
      java.sql.Connection sqlConn=(java.sql.Connection)sqlConnObject;
      try {
        dbJDBCMetadata=ExtractMetaDataUtils.getConnectionMetadata(sqlConn);
      }
 catch (      SQLException e) {
        log.error(e,e);
      }
    }
    conn=MetadataFillFactory.getDBInstance().fillUIConnParams(metadataConnection,null);
    try {
      if (ConnectionUtils.isIngres(prevDataProvider) || ConnectionUtils.isInformix(prevDataProvider) || ConnectionUtils.isDB2(prevDataProvider)) {
        packageFilter=null;
      }
      if (ConnectionUtils.isDB2(prevDataProvider) && connectionParameters.getFilterSchema() != null && !connectionParameters.getFilterSchema().equals("String_Node_Str")) {
        if (packageFilter == null) {
          packageFilter=new ArrayList<String>();
        }
        packageFilter.add(connectionParameters.getFilterSchema());
      }
      MetadataFillFactory.getDBInstance().fillCatalogs(conn,dbJDBCMetadata,packageFilter);
      MetadataFillFactory.getDBInstance().fillSchemas(conn,dbJDBCMetadata,packageFilter);
    }
 catch (    SQLException e) {
      log.error(e);
    }
  }
  if (conn == null) {
    returnProvider.setOk(false);
  }
 else {
    returnProvider.setObject(conn);
  }
  return returnProvider;
}