Program: 137353
Project: 137353
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.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;
}

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 copyedConnection=null;
  if (mdm) {
    copyedConnection=MetadataFillFactory.getMDMInstance().fillUIConnParams(metadataConnection,null);
    MetadataFillFactory.getMDMInstance().fillSchemas(copyedConnection,null,null);
  }
 else {
    SupportDBUrlType currentDBUrlType=SupportDBUrlType.getDBTypeByKey(metadataConnection.getDbType());
    TypedReturnCode<?> trc=(TypedReturnCode<?>)MetadataFillFactory.getDBInstance(SupportDBUrlType.getDBTypeByKey(metadataConnection.getDbType())).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);
      copyedConnection=EObjectHelper.deepCopy(prevDataProvider);
      copyedConnection.getDataPackage().clear();
      MetadataFillFactory.getDBInstance(currentDBUrlType).fillCatalogs(copyedConnection,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,true));
      MetadataFillFactory.getDBInstance(currentDBUrlType).fillSchemas(copyedConnection,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,false));
      ConnectionUtils.closeConnection(sqlConn);
    }
  }
  if (copyedConnection == null) {
    returnProvider.setOk(false);
  }
 else {
    returnProvider.setObject(copyedConnection);
  }
  return returnProvider;
}