This repository was archived by the owner on May 23, 2023. It is now read-only.
Log an error when Scope.close() is called on the incorrect object.#369
Open
carlosalberto wants to merge 1 commit intomasterfrom
Open
Log an error when Scope.close() is called on the incorrect object.#369carlosalberto wants to merge 1 commit intomasterfrom
carlosalberto wants to merge 1 commit intomasterfrom
Conversation
Collaborator
Author
|
Any opinion or similar on this one @yurishkuro @sjoerdtalsma ? |
| public void close() { | ||
| if (scopeManager.tlsScope.get() != this) { | ||
| // This shouldn't happen if users call methods in the expected order. Bail out. | ||
| log.log(Level.SEVERE, "Scope being closed is not the active instance.", |
Contributor
There was a problem hiding this comment.
Personally I would log a warning at this point I think.
Also, wrap the log in an if for the level since you forcefully get a stacktrace.
Side note; My own code is a little more lenient with out-of-sequence closing; it won't touch the active scope, but it will 'mark' the wrong one closed. So when the correct one is closed, it will be 'skipped' in the stack unwinding code since it was already closed out of sequence.
I hope you get the idea, sorry it's still rather early in the morning here 😉
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
A few users have complained about not getting any warning when closing a non-active
Scope, so this PR tries to do a simple warning.(Prior-art wise, grpc's Context implementation does the very same ;) )