public Object processInvocation(final InterceptorContext context) throws Exception { final Map<String, Object> mdc = MDC.getMap(); if (mdc != null) { for (String str : mdc.keySet()) { MDC.remove(str); } } final StoredLogDiagnosticContext data = (StoredLogDiagnosticContext) context.getPrivateData(KEY); context.putPrivateData(KEY, null); if (data != null && data.getMdc() != null) { for (Map.Entry<String, Object> entry : data.getMdc().entrySet()) { MDC.put(entry.getKey(), entry.getValue()); } final int depth = NDC.getDepth(); NDC.push(data.getNdc()); try { return context.proceed(); } finally { NDC.setMaxDepth(depth); for (String str : MDC.getMap().keySet()) { MDC.remove(str); } } } return context.proceed(); } }