Program: 137606
Project: 137606
Buggy source:
public static TypedReturnCode<Connection> getRefreshedDataProvider(Connection prevDataProvider){
  TypedReturnCode<Connection> returnProvider=new TypedReturnCode<Connection>();
  boolean mdm=ConnectionUtils.isMdmConnection(prevDataProvider);
  IMetadataConnection metadataConnection=ConvertionHelper.convert((DatabaseConnection)prevDataProvider,false,prevDataProvider.getContextName());
  Connection conn=null;
  if (mdm) {
    conn=MetadataFillFactory.getMDMInstance().fillUIConnParams(metadataConnection,null);
    MetadataFillFactory.getMDMInstance().fillSchemas(conn,null,null);
  }
 else {
    TypedReturnCode<?> trc=(TypedReturnCode<?>)MetadataFillFactory.getDBInstance().createConnection(metadataConnection);
    Object sqlConnObject=trc.getObject();
    DatabaseMetaData dbJDBCMetadata=null;
    if (trc.isOk() && sqlConnObject instanceof java.sql.Connection) {
      java.sql.Connection sqlConn=(java.sql.Connection)sqlConnObject;
      dbJDBCMetadata=ExtractMetaDataUtils.getDatabaseMetaData(sqlConn,(DatabaseConnection)prevDataProvider);
      conn=MetadataFillFactory.getDBInstance().fillUIConnParams(metadataConnection,null);
      MetadataFillFactory.getDBInstance().fillCatalogs(conn,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(conn,dbJDBCMetadata,true));
      MetadataFillFactory.getDBInstance().fillSchemas(conn,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(conn,dbJDBCMetadata,false));
      ConnectionUtils.closeConnection(sqlConn);
    }
  }
  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);
  IMetadataConnection metadataConnection=ConvertionHelper.convert((DatabaseConnection)prevDataProvider,false,prevDataProvider.getContextName());
  Connection conn=null;
  if (mdm) {
    conn=MetadataFillFactory.getMDMInstance().fillUIConnParams(metadataConnection,null);
    MetadataFillFactory.getMDMInstance().fillSchemas(conn,null,null);
  }
 else {
    TypedReturnCode<?> trc=(TypedReturnCode<?>)MetadataFillFactory.getDBInstance().createConnection(metadataConnection);
    Object sqlConnObject=trc.getObject();
    DatabaseMetaData dbJDBCMetadata=null;
    if (trc.isOk() && sqlConnObject instanceof java.sql.Connection) {
      java.sql.Connection sqlConn=(java.sql.Connection)sqlConnObject;
      dbJDBCMetadata=ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConn,(DatabaseConnection)prevDataProvider);
      conn=MetadataFillFactory.getDBInstance().fillUIConnParams(metadataConnection,null);
      MetadataFillFactory.getDBInstance().fillCatalogs(conn,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(conn,dbJDBCMetadata,true));
      MetadataFillFactory.getDBInstance().fillSchemas(conn,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(conn,dbJDBCMetadata,false));
      ConnectionUtils.closeConnection(sqlConn);
    }
  }
  if (conn == null) {
    returnProvider.setOk(false);
  }
 else {
    returnProvider.setObject(conn);
  }
  return returnProvider;
}