Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Conversation

@carlosalberto
Copy link
Collaborator

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 ;) )

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 76.739% when pulling ee859f4 on log_warning_scope_close into d74e467 on master.

@carlosalberto
Copy link
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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants