refactor if

This commit is contained in:
Loredana Crusoveanu 2018-02-11 21:58:03 +02:00
parent f6efb65fa6
commit 45b4ccf8f6

View File

@ -32,9 +32,16 @@ public class ClientErrorLoggingFilter extends GenericFilterBean {
Authentication auth = SecurityContextHolder.getContext() Authentication auth = SecurityContextHolder.getContext()
.getAuthentication(); .getAuthentication();
if (auth != null) { if (auth == null) {
chain.doFilter(request, response);
return;
}
int status = ((HttpServletResponse) response).getStatus(); int status = ((HttpServletResponse) response).getStatus();
if (status >= 400 && status < 500) { if (status < 400 || status >= 500) {
chain.doFilter(request, response);
return;
}
if (errorCodes == null) { if (errorCodes == null) {
logger.debug("User " + auth.getName() + " encountered error " + status); logger.debug("User " + auth.getName() + " encountered error " + status);
} else { } else {
@ -45,8 +52,6 @@ public class ClientErrorLoggingFilter extends GenericFilterBean {
logger.debug("User " + auth.getName() + " encountered error " + status); logger.debug("User " + auth.getName() + " encountered error " + status);
} }
} }
}
}
chain.doFilter(request, response); chain.doFilter(request, response);
} }