Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDC Servlet Filter, fix typos and be more specific when the MDC values are avaialbe #768

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
* request into the MDC.
* <p/>
* <p/>
* The values are removed after the request is processed.
* The values are removed after the all following
* filters/servlets have been processed. Note, however,
* the value is not available in an error handler servlet.
*
* @author Ceki G&uuml;lc&uuml;
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
import org.slf4j.MDC;

/**
* A simple servlet filter that puts the username
* found either in the Principal.
* A simple servlet filter that stores the username
* found in the Principal in the MDC.
*
* <p> The value is removed from the MDC once the request has been
* fully processed.
* <p> The value is removed from the MDC once all following
* filters/servlets have been fully processed. Note, however,
* the value is not available in an error handler servlet.
*
* @author S&eacute;bastien Pennec
*/
Expand Down Expand Up @@ -74,7 +75,7 @@ public void init(FilterConfig arg0) throws ServletException {
* @return true id the user can be successfully registered
*/
private boolean registerUsername(String username) {
if (username != null && username.trim().length() > 0) {
if (username != null && !username.trim().isEmpty()) {
MDC.put(USER_KEY, username);
return true;
}
Expand Down