
[ http://jira.qos.ch/browse/LBSITE-36?page=com.atlassian.jira.plugin.system.is... ] Ralph Goers commented on LBSITE-36: ----------------------------------- I concur that the way userRegistered is used is not thread safe. However, in this example there is no need to store it in the session or the request. Instead, define registerUserName as private boolean registerUsername(String username) { if (username != null && username.trim().length() > 0) { MDC.put(userKey, username); return truel } return false; } then in doFilter do String userName; if (principal != null) { username = principal.getName(); } else { username = (String) req.getSession().getAttribute(userKey); } boolean userRegistered = registerUserName(userName);
Example 7.5 Is Not Thread-Safe ------------------------------
Key: LBSITE-36 URL: http://jira.qos.ch/browse/LBSITE-36 Project: logback-site Issue Type: Bug Components: Documentation Affects Versions: unspecified Reporter: john jimenez Assignee: Ceki Gulcu
Example 7.5 in http://logback.qos.ch/manual/mdc.html is not thread-safe because userRegistered is declared as a global variable.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira