-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Handle exceptions fix #588
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1bbd6bb
to
1bb1b49
Compare
* Removed legacy onFinishing handler support from JobSupport. - It is no longer needed, because handleJobException covers #208 * Fixed bugs that were masked by cancelling parent from onFinishing. * Consistent "Finishing" state was introduced in internal machinery: - Job enters finishing state when it is failing or it is completing and has children - Finishing state cleanly aggregates all failures, tracks cancellation and completion status * Job.isFailed is introduced as a consistent way to query the "failing" state of the job that was previously only implicitly available via invokeOnCompletion handler (cause != null means a failed job) and the documentation for both Job & Deferred is updated to reflect that. * Source-incompatible change: Job.invokeOnCompletion boolean parameter is change to onFailing. Such handlers are now invoked as soon as the job starts failing and the root cause exception of the failure is consistently passed to all the handlers. * The following internal methods were introduced to facilitate this: - Job.failParent(exception) is used by child to signal failure to parent - Job.cancelChild(parentJob) is used by parent to cancel child. * Child never aggregates exception received from it parent, but uses it as it root cause if there is no other exception. * JobSupport.handleJobException() logic for launch/actor is split into: - failParent - can be invoked multiple times on race; - handleJobException which is invoked exactly once. * Exception materiazization is much lazier now, which should significantly improve performance when cancelling large hierarchies. * Other minor perf improvements in JobSupport code. Fixes #585
Check for simple states on completing before looking for a first child in a potentially long list of job nodes
* ChildHandle.childFailed controls notification from child to parent (no need to lookup parent job in the context) * JobSupport.failsParent boolean property controls whether a job fails its parent on failure.
1bb1b49
to
5d18d02
Compare
* Code style & documentation * Use identity hashset for exception aggregation
qwwdfsad
requested changes
Sep 24, 2018
common/kotlinx-coroutines-core-common/src/CoroutineExceptionHandler.kt
Outdated
Show resolved
Hide resolved
common/kotlinx-coroutines-core-common/src/CoroutineExceptionHandler.kt
Outdated
Show resolved
Hide resolved
…exception handler, so such exception can't break coroutines machinery Fixes #562
Also, it's worth replacing |
Also make JobSupport.onFailing protected instead of internal This will produce nicer stack-traces
We can avoid promotion of Empty to NodeList, but create new empty NodeList and capture it in the new Failing instance
7171128
to
ad84795
Compare
Nope. That does not work. |
* This ensures transparency with respect to the fact that a job is a child in a hierarchy. When it fails, there is no side-effect of its being cancelled by its parent anymore. * ChildJob and ChildHandle are made internal to further deter 3rd-party implementation and usage of parent-child machinery.
b4f0120
to
f7a6334
Compare
* Job.isCancelled is consistently true on any failure * Deferred.isCompletedExceptionally is deprecated. It is equal to isCancelled && isCompleted * CompletableDeferred.completeExceptionally is deprecated. Use cancel instead. Fixes #220
…th play services after rebase
* This makes exception handling fully consistent, since CancellationException is considered "normal", never goes to logs and does not cause parent cancellation. * Solves exception transparency of withTimeout/withTimeoutOrNull -- exception throws from inside gets rethrown outside * Makes sure that closed/cancelled producer that throws ClosedSendChannelException is not considered to be failed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- It is no longer needed, because handleJobException covers Uncaught exception may not appear on console when main is waiting for a job #208
- Job enters finishing state when it is failing or it is completing
and has children
- Finishing state cleanly aggregates all failures, tracks cancellation
and completion status
state of the job that was previously only implicitly available via
invokeOnCompletion handler (cause != null means a failed job) and
the documentation for both Job & Deferred is updated to reflect that.
change to onFailing. Such handlers are now invoked as soon as the job
starts failing and the root cause exception of the failure is consistently
passed to all the handlers.
- Job.failParent(exception) is used by child to signal failure to parent
- Job.cancelChild(parentJob) is used by parent to cancel child.
it as it root cause if there is no other exception.
- failParent - can be invoked multiple times on race;
- handleJobException which is invoked exactly once.
significantly improve performance when cancelling large hierarchies.
Fixes #585