title: How to concat Java Flux lists into one list from external sources
body: <p>In a spring-boot 2.0 rest controller, I have created the following code which works as desired:</p>
  
  <pre><code>@ResponseBody
  @GetMapping("/test3")
  Mono&lt;List&lt;String&gt;&gt; test3(){
      List&lt;String&gt; l1 = Arrays.asList("one","two","three");
      List&lt;String&gt; l2 = Arrays.asList("four","five","six");
  
      return Flux
                 .concat(Flux.fromIterable(l1),Flux.fromIterable(l2))
                 .collectList();
  }
  </code></pre>
  
  <p>My problem comes from trying to do the same thing from an external datasource.  I have created the following test case:</p>
  
  <pre><code>@ResponseBody
  @GetMapping("/test4")
  Flux&lt;Object&gt; test4(){
      List&lt;String&gt; indecies = Arrays.asList("1","2");
      return Flux.concat(
              Flux.fromIterable(indecies)
          .flatMap(k -&gt; Flux.just(myRepository.getList(k))
                            .subscribeOn(Schedulers.parallel()),2
                  )
          ).collectList();
  }
  </code></pre>
  
  <p>Where myRepository is the following:</p>
  
  <pre><code>@Repository
  public class MyRepository {
  
  List&lt;String&gt; l1 = Arrays.asList("one","two","three");
      List&lt;String&gt; l2 = Arrays.asList("four","five","six");
      Map&lt;String, List&lt;String&gt;&gt; pm = new HashMap&lt;String, List&lt;String&gt;&gt;();
  
  MyRepository(){
      pm.put("1", l1);
      pm.put("2", l2);
  }
  
  List&lt;String&gt; getList(String key){
      List&lt;String&gt; list = pm.get(key);
      return list;
  }   
  }
  </code></pre>
  
  <p>My code labeled test4 gives me the code hint error: </p>
  
  <blockquote>
    <p>Type mismatch: cannot convert from Flux&lt; List &lt; String >> to Publisher &lt; ?
    extends Publisher &lt; ? extends Object >></p>
  </blockquote>
  
  <p>So a few questions:</p>
  
  <ol>
  <li>I thought that a Flux was a publisher?  So why the error?</li>
  <li>What am I doing wrong in test 4 so that it will output the same result as in test3?</li>
  </ol>
  
  <p>The expected output is: [["one","two","three","four","five","six"]]</p>