title: java.io.BufferedReader().map Cannot infer type argument(s) for <T> fromStream(Stream<? extends T>)
body: <p>Scenario: a Spring WebFlux triggering CommandLineRunner.run in order to load data to MongoDb for testing purpose.</p>
  
  <p>Goal: when starting the microservice locally it is aimed to read a json file and load documents to MongDb. </p>
  
  <p>Personal knowledge: "bufferedReader.lines().filter(l -> !l.trim().isEmpty()" reads each json node and return it as stream. Then I can map it to "l" and access the get methods. I guess I don't have to create a list and then stream it since I have already load it as stream by "new InputStreamReader(getClass().getClassLoader().getResourceAsStream()" and I assume I can use lines() since it node will result in a string line. Am I in right direction or I am messing up some idea?</p>
  
  <p>This is a json sample file:</p>
  
  <pre><code>{
    "Extrato": {
      "description": "credit",
      "value": "R$1.000,00",
      "status": 11
    },
    "Extrato": {
      "description": "debit",  
      "value": "R$2.000,00",
      "status": 99
    }
  }
  </code></pre>
  
  <p>model</p>
  
  <pre><code>import org.springframework.data.annotation.Id;
  import org.springframework.data.mongodb.core.mapping.Document;
  
  @Document
  public class Extrato {
  
      @Id
      private String id;
      private String description;
      private String value;
      private Integer status;
  
      public Extrato(String id, String description, String value, Integer status) {
          super();
          this.id = id;
          this.description = description;
          this.value = value;
          this.status = status;
      }
  ... getters and setter accordinly
  </code></pre>
  
  <p>Repository</p>
  
  <pre><code>import org.springframework.data.mongodb.repository.Query;
  import org.springframework.data.repository.reactive.ReactiveCrudRepository;
  
  import com.noblockingcase.demo.model.Extrato;
  
  import reactor.core.publisher.Flux;
  import org.springframework.data.domain.Pageable;
  
  public interface ExtratoRepository extends ReactiveCrudRepository&lt;Extrato, String&gt; {
      @Query("{ id: { $exists: true }}")
      Flux&lt;Extrato&gt; retrieveAllExtratosPaged(final Pageable page);
  }
  </code></pre>
  
  <p>command for loading from above json file</p>
  
  <pre><code>import org.springframework.boot.CommandLineRunner;
  import org.springframework.stereotype.Component;
  
  import com.noblockingcase.demo.model.Extrato;
  import com.noblockingcase.demo.repository.ExtratoRepository;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  import reactor.core.publisher.Flux;
  
  @Component
  public class TestDataLoader implements CommandLineRunner {
  
      private static final Logger log = LoggerFactory.getLogger(TestDataLoader.class);
      private ExtratoRepository extratoRepository;
  
      TestDataLoader(final ExtratoRepository extratoRepository) {
          this.extratoRepository = extratoRepository;
      }
  
      @Override
      public void run(final String... args) throws Exception {
          if (extratoRepository.count().block() == 0L) {
              final LongSupplier longSupplier = new LongSupplier() {
                  Long l = 0L;
  
                  @Override
                  public long getAsLong() {
                      return l++;
                  }
              };
              BufferedReader bufferedReader = new BufferedReader(
                      new InputStreamReader(getClass().getClassLoader().getResourceAsStream("carga-teste.txt")));
  
  //*** THE ISSUE IS NEXT LINE
              Flux.fromStream(bufferedReader.lines().filter(l -&gt; !l.trim().isEmpty())
                      .map(l -&gt; extratoRepository.save(new Extrato(String.valueOf(longSupplier.getAsLong()),
                              l.getDescription(), l.getValue(), l.getStatus()))))
                      .subscribe(m -&gt; log.info("Carga Teste: {}", m.block()));
  
          }
      }
  
  }
  </code></pre>
  
  <p>Here is the MongoDb config althought I don't think it is relevant</p>
  
  <pre><code>import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  
  import com.mongodb.MongoClientOptions;
  
  @Configuration
  public class MongoDbSettings {
  
      @Bean
      public MongoClientOptions mongoOptions() {
          return MongoClientOptions.builder().socketTimeout(2000).build();
      }
  
  }
  </code></pre>
  
  <p>If I tried my original code and adjust it for reading a text file I can successfully read text file instead of json. Obvisouly it doesn't fit my demand since I want read json file. By the way, it can clarify a bit more where I am blocked.</p>
  
  <p>load-test.txt (available in <a href="https://github.com/jimisdrpc/webflux-worth-scenarious/blob/master/demo/src/main/resources/carga-teste.txt" rel="nofollow noreferrer">https://github.com/jimisdrpc/webflux-worth-scenarious/blob/master/demo/src/main/resources/carga-teste.txt</a>)</p>
  
  <pre><code>crédito de R$1.000,00
  débito de R$100,00
  </code></pre>
  
  <p>snippet code working with simple text file </p>
  
  <pre><code>    BufferedReader bufferedReader = new BufferedReader(
              new InputStreamReader(getClass().getClassLoader().getResourceAsStream("carga-teste.txt")));
      Flux.fromStream(bufferedReader.lines().filter(l -&gt; !l.trim().isEmpty())
              .map(l -&gt; extratoRepository
                      .save(new Extrato(String.valueOf(longSupplier.getAsLong()), "Qualquer descrição", l))))
              .subscribe(m -&gt; log.info("Carga Teste: {}", m.block()));
  </code></pre>
  
  <p>Whole project working succesfully reading from text file: <a href="https://github.com/jimisdrpc/webflux-worth-scenarious/tree/master/demo" rel="nofollow noreferrer">https://github.com/jimisdrpc/webflux-worth-scenarious/tree/master/demo</a></p>
  
  <p>Docker compose for booting MongoDb <a href="https://github.com/jimisdrpc/webflux-worth-scenarious/blob/master/docker-compose.yml" rel="nofollow noreferrer">https://github.com/jimisdrpc/webflux-worth-scenarious/blob/master/docker-compose.yml</a></p>
  
  <p>To summarize, my issue is: I didn't figure out how read a json file and insert the data into MongoDb during CommandLineRunner.run()</p>