You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MDC usage requires a deep understanding of how it works and gives additional side effects that might not be transparent for regular java developers
public ... process(Orderorder) throws ... {
MDC.put("orderId", order.getId());
MDC.put("customer", order.getCustomerId());
// ... business logic without cleaning MDC thread-local values
}
thus, MDC thread-local variables should be cleaned within the same method
Even, if people know how MDC works/are aware, they might forget to clean in another place in a project or due to staff turnover (which is common in our industry) newcomers might not aware and may make mistakes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
Why?
The MDC usage requires a deep understanding of how it works and gives additional side effects that might not be transparent for regular java developers
thus, MDC thread-local variables should be cleaned within the same method
Even, if people know how MDC works/are aware, they might forget to clean in another place in a project or due to staff turnover (which is common in our industry) newcomers might not aware and may make mistakes.
Beta Was this translation helpful? Give feedback.
All reactions