ensures reactor is backward compatible with latest context propagation changes - #3493
Conversation
…n changes Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
chemicL
left a comment
There was a problem hiding this comment.
Thanks for taking care of the backwards compatibility. I think we need to handle non-automatic mode differently and use the ContextSnapshot.setAllThreadLocals call directly instead of ContextPropagationl.setThreadLocals.
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| static <C> ContextSnapshot.Scope setThreadLocals(Object context) { |
There was a problem hiding this comment.
This method can't be used when automatic context propagation is not enabled - every handle/tap setThreadLocal call did behave differently with regard to missing values - with this change it would clear ThreadLocals for values missing in the context, which is not the case in 3.5.6.
There was a problem hiding this comment.
Right! Good catchup! My bad missed that pice! Thanks
Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
There was a problem hiding this comment.
Overall looks good. However, while use of ContextSnapshotFactory is protected with classpath checks, having it as a static variable leaves it open to potential classpath issues, e.g. some debugger introspecting variables and running into classpath issues it does not expect.
To really isolate the dependency, you could create an internal (private) interface to capture, set thread locals, etc. Then have one implementation for 1.0.3 and another for the existing code. Similar to the SignalListener implementations but behind a private interface.
On the other hand, I expect all these changes to be relatively short-lived. They are only there to cushion the transition to the next maintenance release, and not long after can be phased out. In light of that, the current changes may be good enough for a brief transition period.
followup to #3489
this PR incorporates old changes with the new ones so it makes the reactor backward compatible with context-propagation libs <= 1.0.2