This class implements the doFilter method in the Filter interface.
The below given code snippet explains how diagnostic data is put to the MDC.
try {
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse res = (HttpServletResponse) servletResponse;
HttpSession session = req.getSession();
UserSecurityImplementation userSecurity =
(UserSecurityImplementation)session.getAttribute(USER_SECURITY_KEY);
if (userSecurity != null) {
MDC.put(“USER_ID”, userSecurity.getUserId());
}
Chain.doFilter(request,response)
}
finally {
MDC.remove(“USER_ID”);
}
After one EJB has finished serving first request and before removing the
MDC from UI layer for the same request, is it possible that the bean (and in
turn the running thread) be allocated to next request? This will cause the
previous user id information to be logged erraneously. Will this happen?
The below given code snippet explains how diagnostic data is put to the MDC.
try {
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse res = (HttpServletResponse) servletResponse;
HttpSession session = req.getSession();
UserSecurityImplementation userSecurity =
(UserSecurityImplementation)session.getAttribute(USER_SECURITY_KEY);
if (userSecurity != null) {
MDC.put(“USER_ID”, userSecurity.getUserId());
}
Chain.doFilter(request,response)
}
finally {
MDC.remove(“USER_ID”);
}
After one EJB has finished serving first request and before removing the
MDC from UI layer for the same request, is it possible that the bean (and in
turn the running thread) be allocated to next request? This will cause the
previous user id information to be logged erraneously. Will this happen?