-
Notifications
You must be signed in to change notification settings - Fork 25
[HOLD] Unifying ContextSnapshot vocabulary and fixing setAllThreadLocalsFrom #73
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
[HOLD] Unifying ContextSnapshot vocabulary and fixing setAllThreadLocalsFrom #73
Conversation
context-propagation/src/main/java/io/micrometer/context/ContextSnapshot.java
Outdated
Show resolved
Hide resolved
context-propagation/src/main/java/io/micrometer/context/ContextSnapshot.java
Outdated
Show resolved
Hide resolved
🛠 Lift Auto-fixSome of the Lift findings in this PR can be automatically fixed. You can download and apply these changes in your local project directory of your branch to review the suggestions before committing.1 # Download the patch
curl https://lift.sonatype.com/api/patch/github.com/micrometer-metrics/context-propagation/73.diff -o lift-autofixes.diff
# Apply the patch with git
git apply lift-autofixes.diff
# Review the changes
git diff Want it all in a single command? Open a terminal in your project's directory and copy and paste the following command: curl https://lift.sonatype.com/api/patch/github.com/micrometer-metrics/context-propagation/73.diff | git apply Once you're satisfied, commit and push your changes in your project. Footnotes |
…ibrary. Dependent upon merge of micrometer-metrics/context-propagation#73
Recent change to `ContextSnapshot#setThreadLocals()` method allows to clear `ThreadLocal` values not present in the snapshot. The associated change to `ContextSnapshot.setAllThreadLocalsFrom(sourceContext)` should be on par with `ContextSnapshot.captureAll(...)` followed by `ContextSnapshot#setThreadLocals()` but avoiding the temporary snapshot container. Unfortunately, the method clears existing `ThreadLocal` values that are not present in the sourceContext object and creates a mismatch in the vocabulary. The previous behaviour is restored for that static method. Instead, two new static methods are introduced: - `ContextSnapshot.setThreadLocals(Object)` - `ContextSnapshot.setThreadLocals(Object, ContextRegistry)` that allow to skip the temporary container and clear `ThreadLocal` values not present in the sourceContext provided and set only the present ones.
18e0306
to
aacbb3c
Compare
Putting on hold. #74 reverts the previous functionality. This PR should serve as basis for a unification of the API and brining the choice to clear ThreadLocal values that are not present in a source context object vs only setting present values and ignoring others. Both scenarios have their place in application usage patterns and the API should allow an informed interaction. |
Closing this one in favour of #105. |
Recent change to
ContextSnapshot#setThreadLocals()
method allows to clearThreadLocal
values not present in the snapshot.The associated change to
ContextSnapshot.setAllThreadLocalsFrom(sourceContext)
should be on par withContextSnapshot.captureAll(...)
followed byContextSnapshot#setThreadLocals()
but avoiding the temporary snapshot container.Unfortunately, the method clears existing
ThreadLocal
values that are not present in the sourceContext object and creates a mismatch in the vocabulary.The previous behaviour is restored for that static method.
Instead, two new static methods are introduced:
ContextSnapshot.setThreadLocals(Object)
ContextSnapshot.setThreadLocals(Object, ContextRegistry)
that allow to skip the temporary container and clear
ThreadLocal
values not present in the sourceContext provided and set only the present ones.