jayblanc commented on code in PR #696:
URL: https://github.com/apache/unomi/pull/696#discussion_r1778290216


##########
rest/src/main/java/org/apache/unomi/rest/exception/ValidationExceptionMapper.java:
##########
@@ -29,17 +29,13 @@
 @Provider
 @Component(service = ExceptionMapper.class)
 public class ValidationExceptionMapper implements 
ExceptionMapper<ConstraintViolationException> {
-    private static final Logger logger = 
LoggerFactory.getLogger(ValidationExceptionMapper.class.getName());
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ValidationExceptionMapper.class.getName());
 
     @Override
     public Response toResponse(ConstraintViolationException exception) {
         exception.getConstraintViolations().forEach(constraintViolation -> {
-            if (logger.isDebugEnabled()) {
-                logger.debug(String.format("value %s from %s %s", 
constraintViolation.getInvalidValue(),
-                        constraintViolation.getPropertyPath().toString(), 
constraintViolation.getMessage()), exception);
-            }
-            logger.error(constraintViolation.getPropertyPath().toString() + " 
" + constraintViolation.getMessage() + ". Enable debug log "
-                    + "level for more informations about the invalid value 
received");
+            LOGGER.error("{} {}. {}", constraintViolation.getPropertyPath(), 
constraintViolation.getMessage(), (LOGGER.isDebugEnabled())?"":"Enable debug 
log level for more information about the invalid value received");
+            if (LOGGER.isDebugEnabled()) LOGGER.debug("value {} from {} {}", 
constraintViolation.getInvalidValue(), constraintViolation.getPropertyPath(), 
constraintViolation.getMessage(), exception);

Review Comment:
   In fact, if we remove the condition, the getInvalidValue(), 
getPropertyPath() and getMessage() will be evaluated even if not in debug and 
those method may have a cost so, when there is some methods call in the log 
params keeping the condition may be safer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@unomi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to