Closed spring-projects-issues closed 7 years ago
Brian Clozel commented
This tracker is meant for issues or enhancement requests; for questions, please create a new question on StackOverflow.
In this case, Flux.fromArray
will emit each array element as a value in the resulting Flux
.
You're assuming that asking the WebClient
for a Flux<String>
will split on new lines but it's not true. It will just randomly split on chars, depending on what's read on the network and the demand on the reactive stream itself. You can compose that Flux with another operator to split on new lines (see Spring's StringDecoder
), or you can configure the client codecs to split text on new lines, there's an option for that.
chao chang opened SPR-16148 and commented
I'm using web client to retrieve a text file,and then calculate the top N frequent words. the lines flux created from bodyToFlux() method seems does not work(the consumer of topFreqWords is not called).Alternatively if the lines flux is created from a string array,the program works properly. And,if we just subscribe to the lines flux created from bodyToFlux(),the consumer does get called. if we subscribed to wordGoups flux,the consumer will be called. But if we subscribed to wordCounts,the consumer will not be called.
The below is the code snippet.
Affects: 5.0.1
Reference URL: https://github.com/chang-chao/top-freq-words/blob/master/src/main/java/me/changchao/reactive/topfreqwords/TopFreqWordCounter.java