0

I'm trying to write a test to see the use of onBackPressureDrop in RxScala.

I'm zipping a fast Obserable with a slow one, with a simple zipping function.

The curious thing is that the same example in RxJava produces the exception but with RxScala it seems to not need the onBackPressureDrop instruction.

The test looks like the following:

  @Test def testWithoutBackPressure() {
    val fast = Observable.interval(1 millis).take(100)
    val slow = Observable.interval(1000 millis).take(100)

    val res = fast.zipWith(slow)(_*_)

    res.subscribe(
      n => { println("[testWithoutBackPressure] " + n) },
      e => e.printStackTrace(),
      () => println("testWithoutBackPressure done")
    )

  }

How can I make this code fail because of the absence of backpressure?

juanpavergara
  • 1,511
  • 1
  • 11
  • 22

1 Answers1

0

The default internal buffer size in RxJava is 128. So your codes won't throw MissingBackpressureException. I also rewrote your codes to Java and didn't see MissingBackpressureException.

Therefore, you can change take(100) to take(1024) to make it throw MissingBackpressureException.

zsxwing
  • 20,270
  • 4
  • 37
  • 59