Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare work on 3.2.0, integrate error mode (for MILESTONE 1) #1021

Merged
merged 21 commits into from
Jan 10, 2018

Conversation

simonbasle
Copy link
Member

The plan is to use the 3.2.0-prepare branch to work on 3.2-specific features while we are still officially on the 3.1.x line.

simonbasle and others added 21 commits January 10, 2018 10:15
this second commit makes resume() cancel the upstream and add the
original error as suppressed in case of a consumer failure.

it also adds a conditionalResume() that only applies to failures
matching the BiPredicate, falling back to STOP for other failures. Once
again, if the predicate or consumer fail, the original error is added to
the exception as suppressed and the later is passed to STOP.

Added unit tests of both customizable strategies.
The API takes BiConsumer<Throwable, T>, although these are brutally
casted down to Object in the underlying implementations
as doOn* operators don't change the sequence, it makes no sense calling
the strategy with a value. Having the predicate only deal with the
Throwable and the BiConsumers split into valueConsumer vs errorConsumer
allows for more flexibility, taking the peek use case into account with
the same strategy method.
 - strategy now checks if `canResume` and can then `process`
 - "stop" fallback now entirely done in Operators#onNextFailure, which
 is a util for the 80% use case (dealing with failure in onNext)
 - added Operators method to just get the strategy
 - FluxPeek uses that to specifically deal with some callback errors,
 as these don't modify the source sequence when recovered from.
 - strategy processing can return a Throwable
 - default strategies catch consumer errors and return them, suppressing
 the original error
 - if strategy returns a Throwable, the Operators.onNextFailure util
 will cancel the subscription
 - evaluation of throwIfFatal is made as late as possible in order for
 strategies to be able to recover from a fatal exception if strategy
 has a predicate that explicitly matches that exception type (not a
 joker null predicate)
  - resume strategy with value consumer passes `null` along to the
  consumer which should be prepared to receive such a value. unused for
  now.

 In order to help with tests, the `AssertSubscriber` can now be built
 with a customized Context.
see also discussion in PR #957
@simonbasle simonbasle merged commit ce62135 into 3.2.0-prepare Jan 10, 2018
@smaldini smaldini deleted the 629-errorMode branch January 23, 2018 00:20
simonbasle added a commit that referenced this pull request Feb 16, 2018
See #629 and #840

This commit adds an error strategy concept to some of the operators
that let `Flux` and `Mono` recover from an error mid-stream: the
`continue` strategy.

Such errors are dropped into a special hook, and the sequence can
continue with the next value from the upstream.

Operators that support this mode have a special tag in their javadoc.
These include `map`, `filter`, `flatMap`, `handle`, `doOnNext`.

The error mode is activated using `Context`, so it follows the same
propagation semantics. The API is on `Flux`:

  - `errorStrategyContinue(...)` will activate the continue strategy for
  that particular `Flux`, upstream of it.
  - `errorStrategyStop()` let you go back to the default RS behavior,
  eg. in case you don't want the continue strategy to apply within a
  `flatMap`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants