refactor if

This commit is contained in:
Loredana Crusoveanu 2018-02-11 21:58:03 +02:00
parent f6efb65fa6
commit 45b4ccf8f6
1 changed files with 18 additions and 13 deletions

View File

@ -32,19 +32,24 @@ public class ClientErrorLoggingFilter extends GenericFilterBean {
Authentication auth = SecurityContextHolder.getContext()
.getAuthentication();
if (auth != null) {
int status = ((HttpServletResponse) response).getStatus();
if (status >= 400 && status < 500) {
if (errorCodes == null) {
logger.debug("User " + auth.getName() + " encountered error " + status);
} else {
if (errorCodes.stream()
.filter(s -> s.value() == status)
.findFirst()
.isPresent()) {
logger.debug("User " + auth.getName() + " encountered error " + status);
}
}
if (auth == null) {
chain.doFilter(request, response);
return;
}
int status = ((HttpServletResponse) response).getStatus();
if (status < 400 || status >= 500) {
chain.doFilter(request, response);
return;
}
if (errorCodes == null) {
logger.debug("User " + auth.getName() + " encountered error " + status);
} else {
if (errorCodes.stream()
.filter(s -> s.value() == status)
.findFirst()
.isPresent()) {
logger.debug("User " + auth.getName() + " encountered error " + status);
}
}