title: Flux into Mono List Object - project reactor
body: <p>I'm using project reactor and I've the next issue:</p>
  <p>I've one method that return <code>Mono&lt;CustomerResponse&gt;</code> that contains a CustomerDto list, each client has attributes, one of theirs attributes is a payment list. But this payment list is null.</p>
  <p>I've another method that receive client id and returns a Flux payment <code>Flux&lt;PaymentDto&gt;</code> for that client.</p>
  <p>This are the model</p>
  <pre><code>public class CustomerResponse {
      private List&lt;CustomerDto&gt; customers;
  }
  
  public class CustomerDto {
      private int id;
      private String fullname;
      private String documentNumber;
      private List&lt;PaymentDto&gt; payments;
  }
  </code></pre>
  <p>These are the interfaces</p>
  <pre><code>public interface CustomerService {
      public Mono&lt;CustomerResponse&gt; customerSearch(CustomerRequest request);
  }
  public interface PaymentService {
      public Flux&lt;PaymentDto&gt; getPayments(int clientId);
  }
  </code></pre>
  <p>This is my method</p>
  <pre><code>public Mono&lt;CustomerResponse&gt; getCustomer(CustomerRequest request) {
      return customerService.customerSearch(request).map(resp -&gt; resp.getCustomers())
              .flatMap(customerList -&gt; {
                  List&lt;CustomerDto&gt; newCustomerList = customerList.parallelStream().map(customer -&gt; {
                      Flux&lt;PaymentDto&gt; paymentFlux = 
                              paymentService.getPayments(customer.getId());
                      
                      // Here: java.lang.IllegalStateException: block()/blockFirst()/blockLast()
                      customer.setPayments(paymentFlux.collectList().block());
                      return customer;
                  }).collect(Collectors.toList());
                  
                  return Mono.just(new CustomerResponse(newCustomerList));
              });
  }
  </code></pre>
  <p>I've the next exception:</p>
  <pre><code>java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-4
      at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.3.6.RELEASE.jar:3.3.6.RELEASE]
      Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
  </code></pre>
  <p>I would like to know if there is a non-blocking or optimal way to do it</p>