This is the MILESTONE 1 release of Reactor 3.1.0, which will be part of the Bismuth Release Train.
This MILESTONE covers API changes of the upcoming 3.1.0 release, as well as a few improvements.
Most API changes have been introduced using a deprecate-and-offer-alternative strategy in the latest releases in the 3.0.x branch.
However, please have a look at the section below for update considerations if you haven't progressively updated each new 3.0.x.
⚠️ Update considerations and API changes
- From a general perspective, most deprecated elements in 3.0.x have now been removed (#323)
- ⚠️
Mono.then(Function)andMono.flatMap(): how to migrate (#516):- first replace all usage of
Mono.flatMapwithflatMapMany - then replace all usage of
Mono.then(Function)(which has been removed) withflatMap. - the gist of this change is that the old
flatMapwas actually changing the return type toFluxand was thus missing the "Many" suffix we usually use. At the same time,then(Function)was transforming the source value (unlike any other form ofthenwhich usually just ignore the emissions and act on the onComplete). Thus it was actually more of aflatMap.
- first replace all usage of
- error handling operators have been made more consistent between
MonoandFlux(#533, #535, #531)Flux: onErrorResumeWith ->onErrorResume, mapError ->onErrorMap, switchOnError -> replace withonErrorResumewith a lambda that ignores the left hand side.Mono: otherwise ->onErrorResume, otherwiseReturn ->onErrorReturn, otherwiseIfEmpty ->switchIfEmpty, mapError ->onErrorMap
- buffer operators that take a
(Publisher, Function)as arguments (open boundary and closing selector) have been renamed tobufferWhen. This improves the situation where having multiple lambda-based signature can create ambiguity (even more so in languages like Kotlin) (#542) delayinFluxis removed in favor ofFlux.delayElements(see #263)doAfterTerminatedoesn't cause anonErrorsignal if its callback fails (#270)- then:
- variants of
thenthat took aSupplierhave been removed. Usedeferif you really need to provide the continuationMonolazily (#547) Flux.then(Publisher<Void>)has been removed in favor ofthenEmptyMono.then(Function)is nowMono.flatMap(see 1st entry)
- variants of
- window:
- various window operators have been aligned in behavior with respect to cancellation (#384)
windowoperators that take a(Publisher, Function)as arguments (open boundary and closing selector) have been renamed towindowWhen. This improves the situation where having multiple lambda-based signature can create ambiguity (even more so in languages like Kotlin) (#542)Flux.window()has been removed in favor ofwindow(Publisher),windowUntilandwindowWhile(see #260)
zip(Iterable)inFluxhas been removed as it was by nature unusable (#338)- Cross operator changes based on prefix / parameter pattern:
- xxxMillis: Timed operators with the
Millissuffix have been removed, use theirDurationbased counterparts xxx(boolean delayError): All operators that were taking adelayErrorboolean parameter instead of having aDelayErrorsuffixed variant now use the suffix variant pattern (see #480)xxx(Function<Throwable, ?>): Operators dealing with aPredicateorFunctionofThrowablehave been aligned to take a more generic<? super Throwable>- All
subscribemethods inFluxthat had a prefetch parameter have been removed (you can uselimitRateto achieve the same effect)
- xxxMillis: Timed operators with the
- Removal of interfaces and classes:
- Old introspection interfaces, which were mostly only used internally, have been removed in favor of the single
Scannableinterface (Loopback, MultiProducer, MultiReceiver, Producer, Receiver, Trackable, see #249, 20bd64d) Cancellationhas been removed and replaced withDisposable(see #322, 844769d)TimedSchedulerhas been removed, as well as theScheduler#shutdownmethod (all schedulers are now time capable and you can usedispose(). Note that most timed operators now use theparallel()Scheduler by default. see #451, #322)
- Old introspection interfaces, which were mostly only used internally, have been removed in favor of the single
- Processors have been reworked. Notably you cannot connect explicitly anymore but should rather use the
sink()method. For details and rationale, see #525. - Some changes have been made to
Operatorssupport class for writing custom operators:Operators.SubscriberAdapteris not part of the public API anymore.Operators.addAndGet(AtomicLong, ...)has been removed in favor of theAtomicLongFieldUpdateralternative.
✨ New features and improvements
- Added a
Flux.then(Mono)operator to align with the Mono equivalent (#547) - Added
Mono.delayUntilandMono.delayUntilOtherto delay the emission of a Mono until after a companion Publisher completes (which can be generated from the source value in the case ofdelayUntil). This is very close tountilOtherexcept it acts on onComplete. (#558, #568) - The error message in case some operators badly behave with backpressure ("Queue full?!") has been made more explicit (#540)
ParallelSubscribernow has asubscribe()method and allsubscribe(...)methods are final like inFlux(#564)
🪲 Bug fixes
Mono.untilOtherwould not return a new instance when chained with itself (#515)Operators#setOncewas cancelling the wrong subscription
📖 Documentation, Tests and Build
- The javadoc has been reviewed and polished across the board. Most notably, a full review of
FluxandMonojavadoc has been made. It also now outputs UTF-8 html, and a few marble diagrams were added (#545, #559, #528, #513, #544) - the reference documentation has been updated to keep up with new/modified operators (#516, #535, #555)
👍 Thanks to the following contributors that also participated to this release
@rajinisivaram, @sdeleuze, @schauder, @Dmitriusan, @garyrussell