reactor / reactor-core

Non-Blocking Reactive Foundation for the JVM
http://projectreactor.io
Apache License 2.0
4.93k stars 1.2k forks source link

Lost messages vulnerability when using `buffer` and `bufferTimeout` operators #1137

Closed DavidDuwaer closed 6 years ago

DavidDuwaer commented 6 years ago

Vulnerability

When using batching operators, e.g. buffer and bufferTimeout, that return a Flux<List<T>>, put events in lists (not sure if I'm following the correct lingo here, but when I write "event" I mean the object of type "T" in a Flux<T>). In subsequent operators (e.g. .map or .onNext), elements can be removed from the list, leading to loss of events. While one should be free to pass Lists through Fluxes and Monos as if the List is the type of the event itself, having buffer and bufferTimeout return the List type encourages putting seperate events into lists.

Solution suggestion

akarnokd commented 6 years ago

This is not a vulnerability or even a bug. Those lists are free to get manipulated after they leave buffer. Imagine you can even add new events in doOnNext! You can wrap them into immutable datastructures after as you see fit via map.

Also there are the window operators already that return Flux<Flux<T>>.