jvz commented on a change in pull request #287: adding support for session 
attributes in log4j-web
URL: https://github.com/apache/logging-log4j2/pull/287#discussion_r320454341
 
 

 ##########
 File path: log4j-web/src/main/java/org/apache/logging/log4j/web/WebLookup.java
 ##########
 @@ -91,6 +93,18 @@ public String lookup(final LogEvent event, final String 
key) {
                     HttpServletRequest.class.cast(req).getParameter(name) : 
null;
         }
 
+        if (key.startsWith(SESSION_ATTR_PREFIX)) {
+            final ServletRequest req = getRequest();
+            if (HttpServletRequest.class.isInstance(req)) {
 
 Review comment:
   Why the reflection? You could change this to be:
   
   ```
   if (req instanceof HttpServletRequest) {
     final HttpSession session = ((HttpServletRequest) req).getSession(false);
     // ...
   }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to