Skip to content

ReplaySubject emits items received after onError #544

Closed
@samuelgruetter

Description

@samuelgruetter

This snippet

    val sub = ReplaySubject[Int]()

    sub.onNext(1)
    sub.onNext(2)
    sub.onError(new Exception("Kabloooy!")) // Gets moved to after onNext(3)
    sub.onNext(3)

    sub.subscribe(
      n => println("sub1: " + n),
      e => println("sub1: " + e.getMessage),
      () => println("sub1: completed")
    )

    println("done")

outputs

sub1: 1
sub1: 2
sub1: 3
sub1: Kabloooy!
done

but I would expect

sub1: 1
sub1: 2
sub1: Kabloooy!
done

since items received after onError should not be emitted by ReplaySubject.

(Thank you Dragisa Krsmanovic for pointing this out)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions