-
Notifications
You must be signed in to change notification settings - Fork 534
2.13 refinement/explanation #328
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
Comments
We need to avoid having negative rules, and instead focus on speccing the only compliant behavior. Citing the full rule here:
In the last sentence
Do you think adding a footnote for |
I'm probably missing something, but why can't a Publisher just ignore the exception and let it bubble up the call stack (except for the case where this occurs inside subscribe, which is indeed forbidden by §1.9)? Maybe this is actually adequate behavior for a runtime environment in which the thread pool handles any exceptions itself? |
@anthonyvdotbe If you think about it: which capacity is the Thread which runs the Publisher equipped to handle the failures of the Subscriber (which could "run" on some other machine)? |
@viktorklang couldn't the Publisher rely on e.g. ThreadPoolExecutor::afterExecute, or the Thread's UncaughtExceptionHandler? |
@anthonyvdotbe How would that know what to do with it, and how would the Publisher recover if it blows its own stack? |
I believe this:
is what I'd been missing all along. So am I correct in saying the caller MUST be able to recover from violations of rule 2.13? If so, I fully get it & would like rule 2.13 to end as:
Either way, thanks for your help @viktorklang |
@anthonyvdotbe I'm not sure that solves your problem, it only shifts it to the definition of "be able to recover". See it like this: The rule is about what the Publisher should do if the Subscriber violates the spec. Technically the spec could omit that, but for the sake of resilience, we don't want those exceptions to propagate, because imagine a "pipeline" of 1 publisher + 1 processor + 1 processor + 1 subscriber where each of these live in different JVMs, since there is no exception backchannel, only a demand backchannel, there's no way to propagate the exception "backwards" in the chain, which means that the exceptions need to be dealt with locally. This is why non-fatal exceptions are not allowed to be thrown (except for the rules which state otherwise). I'd like to make these kinds of things (the rationale for each of the rules) as transparent as possible, and I regrettably still haven't had time to sit down and for each rule write a rationale so that the "casual reader" can gain a deeper understanding of why the rules are as they are. |
Thanks @viktorklang, I'm starting to get it. Yes, being a casual reader myself, it would definitely be helpful to have these rationales & insights (e.g. the fact that different components of a pipeline might run in different JVMs) available along with the specification. I learned about reactive streams by looking into Java 9's Flow API, and I'd guess the number of casual readers will grow substantially once Java 9 is released. |
@anthonyvdotbe Perhaps this summer, during my vacation, I'll find some time to distill these things :) |
Apologies for the delay here, fixed in #339 |
§2.13 says:
I've asked about this, and @viktorklang replied saying:
This reply contains a vital point which I didn't get from reading the rule, namely that the caller should not rethrow the exception. To make this clear, I propose to add an additional phrase for this to the rule:
The text was updated successfully, but these errors were encountered: