title: Why does project reactor hang indefinitely when switchIfEmpty is used?
body: <p><strong>Background</strong></p>
  
  <p>I'm using Spring Boot 2.2.1, project-reactor 3.3.0 and spring-data-mongodb 2.2.1 and I'm trying to load data from multiple queries. My code looks roughly like this:</p>
  
  <pre><code>Flux.just("type1", "type2", "type3", "type4")
      .concatMap { type -&gt;
          reactiveMongoOperations.find&lt;Map&lt;String, Any&gt;&gt;(BasicQuery("{'type': '$type'}"), "collectionName")
                                  .doOnError { e -&gt;
                                      log.error("Caught exception when reading from mongodb: ${e::class.simpleName} - ${e.message}", e)
                                  }.switchIfEmpty {
                                      log.warn("Failed to find any documents of type $type")
                                      Mono.empty&lt;Map&lt;String, Any&gt;&gt;()
                                  }
      } 
      .. // More operations here
      .subscribe()
  </code></pre>
  
  <p>The problem is that if <code>reactiveMongoOperations.find(..)</code> doesn't find any documents for a given type (and thus <code>"Failed to find any documents of type $type"</code> is logged) the entire operation will just hang indefinitely. If I remove the <code>switchIfEmpty</code> clause the operations completes and everything works fine.</p>
  
  <p><strong>Questions</strong></p>
  
  <ol>
  <li>Why does the entire operation just hang if I add the <code>switchIfEmpty</code> operation? It doesn't matter if I use <code>flatMap</code> instead of <code>concatMap</code>, it will hang eventually anyways.</li>
  <li>How should I log that no documents are found for the particular query? I.e. I want to log that no documents were found when <code>reactiveMongoOperations.find(..)</code> returns an empty <code>Flux</code>.</li>
  </ol>