title: Mono.onErrorResume() doesn't always work as expected
body: <p>I'm not sure whether there is something wrong with my code or is it a bug in the reactor-core.
  What i'm trying to do is to handle errors such as OptimisticLockingFailureException that happens when different threads are trying to save the same database record/entity at the same moment.</p>
  <p>the example below is just a simpler form of what i have in the code and assuming that i have a main stream that contains a lot of operations and a sub-stream with the issue i have that should be executing some database calls using reactive mongo which is represented here with &quot;processFlux()&quot; method.</p>
  <p>I'm applying a retry using onErrorResume() to call the same method from inside the &quot;errorFallBack()&quot; and my code goes like this:</p>
  <pre><code>import reactor.core.publisher.Flux;
  
  
  public class TestClass1 {
  
      public static void main(String[] args) {
          Flux.range(1,10)
                  .doOnNext(System.out::println)
                  .publish(integerFlux -&gt; processFlux(integerFlux))
                  .doOnNext(System.out::println)
                  .onErrorContinue((throwable, o) -&gt; System.out.println(&quot;on error continue!!!&quot;))
                  .subscribe(x -&gt; sleepMillis(100));
      }
  
      private static void sleepMillis(long millis) {
          try {
              Thread.sleep(millis);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  
      public static Flux&lt;Integer&gt; processFlux(Flux&lt;Integer&gt; input) {
          return input
                  .map(integer -&gt; {
                      if (integer == 5)
                          throw new NumberFormatException();
                      return integer;
                  })
                  .onErrorResume(NumberFormatException.class, e -&gt; errorFallBack(input));
      }
  
      private static Flux&lt;Integer&gt; errorFallBack(Flux&lt;Integer&gt; input) {
          return input
                  .doOnNext(integer -&gt; System.out.println(&quot;inside errorFallBack()&quot;))
                  .flatMap(integer -&gt; processFlux(Flux.just(integer)));
      }
  }
  </code></pre>
  <p>in the &quot;processFlux()&quot; method i assume there will be an exception thrown at some point of time and i try to catch it with the &quot;onErrorResume()&quot;.</p>
  <p>Since i'm using &quot;publish()&quot; in the main stream to wrap around &quot;processFlux()&quot; i expect that when the error happens the &quot;onErrorResume()&quot; is the one that will be called...the actual behaviour is that the &quot;onErrorContinue()&quot; of the min stream is the one that is being called.</p>
  <p>is this a bug? or shall i change something in my code?</p>
  <p>I'm using reactive mongo with spring boot 2.1.13.RELEASE,
  spring cloud version Greenwich.SR5
  and reactor-core version 3.3.6.RELEASE</p>