-
Notifications
You must be signed in to change notification settings - Fork 531
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
provides clarification on the 1.9 rule #494
base: master
Are you sure you want to change the base?
Conversation
43eb7f9
to
0e3ca22
Compare
9e727f9
to
352b397
Compare
It seems that |
@OlegDokuka Can you describe the failed test? |
The idea is to mandate calling Due to my findings, final void onSubscribe() {
startOnSignal(RUN | ACTIVE);
}
final void startOnSignal(int bits) {
if ((ctl & bits) != bits &&
(getAndBitwiseOrCtl(bits) & (RUN | CLOSED)) == 0)
tryStart();
}
/**
* Tries to start consumer task. Sets error state on failure.
*/
final void tryStart() {
try {
Executor e;
ConsumerTask<T> task = new ConsumerTask<T>(this);
if ((e = executor) != null) // skip if disabled on error
e.execute(task);
} catch (RuntimeException | Error ex) {
getAndBitwiseOrCtl(ERROR | CLOSED);
throw ex;
}
} |
This is a drastic change and I don't understand why you'd want to add this limitation. |
@akarnokd I guess that was a drastic misunderstanding of how it should work. Imagine that The correct answer - nohow. Because we neither know which worker responsible for the execution, nor allowed to terminate the whole associated Along, From my standpoint that is a clear violation of the spec and reactive-streams should not work that way. This PR just clarifies the 1.9 rule and fixes such misbehavior |
If this is a failure mode for your use case, don't use an operator that schedules onSubscribe. Also thete is a limit on how much infrastructure failures we can work aroud, i.e. can't do much when trying to schedule with a shut down executor for example. I don't support this change to the spec/tck. Instead let's look at the original issue and have a workaround/solution there. |
Well. Sounds like solving symptoms rather than solving the root cause. And yeah - the workaround is simple - do not offload anything related to the |
Your solution breaks at least one established implementation that passed before. I'd also think this could break Akka Stream as they tend to schedule all sorts of signals. |
I'm not pushing to merge it right now. That discussion started at #486 and ended saying that we do not have to offload the If we know that there is an extensive number of libraries using that - let's discuss how to bring that breaking clarification up, so all the vendors will have time to fix this issue. |
@OlegDokuka SubmissionPublisher calls Subscriber.onSubscribe synchronously. It does not trap exceptions from the call, so they will be rethrown. I suppose this could be changed, but whatever is done would be outside of spec because onSubscribe should not throw. See code at http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/SubmissionPublisher.java?view=log |
That is not true. The execution stack is the following
Please, notice, at point 5, the tasks is offloaded to the
Nobody is talking about exceptions in The PR here makes sure every It means that the following is ✅
whiles the next is ❌
|
@OlegDokuka Here is the code. It looks synchro9nous to me:
|
@DougLea You have all the references to the execution stack, we can debate forever, but it is better to check it first before. Also the main difference between
is that it is not equal to
|
@OlegDokuka Sorry for the confusion. You are right that user.onSubscribe method can be performed async. |
This PR changes:
onSubscribe
must be called synchronously within thesubscribe
methodsubscribe
method callAsyncIterablePublisher
to cal onSubscribe immediately with no offloading to the schedulercloses #486