sonatype/nexus-oss — pull request #48 by cstamas (2013-06-21 12:22:26+00:00)
Title: NEXUS-5753: MDC cleanup

We started using MDC with the addition of the filter to the Nexus webapp.

Later, we realised this is not quite good, as scheduled task's thread pool, Autorouting thread pool and other "inherit" the MDC of first invocation (like in case of manual running a scheduled task, thread will inherit the MDC of running user, and as thread is pooled, same userId will be displayed for scheduled task running on that thread even if the displayed user is logged out since eons).

This change "bolts on" the Subject related changes, as the technicalities are pretty much very similar. ShiroScheduledExecutorService renamed to Nexus*, as it does not handle with Shiro's Subject only anymore.

MDC will be handled now properly, not only on QTP threads (where filter was handling it already as should, but it was "leaking into other managed threads), but on all the pools to be found in Nx core, such as Scheduled Tasks, Auto routing, Async EventInspectors etc.

The change will make that whole user action become "user identified" even in case of cascading over threads (like a QTP thread fires and event, it get's processed by async event inspector, and a background job gets scheduled, like when user logs in, and enables Idx download on Central). Also, no more "stale" userIds will be shown, as MDC will be explicitly managed on all managed threads in Core.