- Notifications
You must be signed in to change notification settings - Fork 13
Description
Logback Access 2.0.1 and Jetty 11. (Probably also occurs in the previous Logback Access 1.4 series.
The issue occurs because the Jetty web server recycles org.eclipse.jetty.server.Request Objects. When the server completes processing a given Request object, the server recycles the Request Object. After the Request Object is recycled, any various data related to the previous request will no longer be available. For example, if using an appender that processes asynchronously, the Request object may be recycled before logging.
AccessEvent has prepareForDeferredProcessing method to avoid this, but the cookie is not considered here.
logback-access/common/src/main/java/ch/qos/logback/access/common/spi/AccessEvent.java
Lines 623 to 645 in 40fada8
| public void prepareForDeferredProcessing() { | |
| getRequestHeaderMap(); | |
| getRequestParameterMap(); | |
| getResponseHeaderMap(); | |
| getLocalPort(); | |
| getMethod(); | |
| getProtocol(); | |
| getRemoteAddr(); | |
| getRemoteHost(); | |
| getRemoteUser(); | |
| getRequestURI(); | |
| getRequestURL(); | |
| getServerName(); | |
| getTimeStamp(); | |
| getElapsedTime(); | |
| getStatusCode(); | |
| getContentLength(); | |
| getRequestContent(); | |
| getResponseContent(); | |
| copyAttributeMap(); | |
| } |
logback-access/common/src/main/java/ch/qos/logback/access/common/spi/AccessEvent.java
Lines 457 to 473 in 40fada8
| @Override | |
| public String getCookie(String key) { | |
| if (httpRequest != null) { | |
| Cookie[] cookieArray = httpRequest.getCookies(); | |
| if (cookieArray == null) { | |
| return NA; | |
| } | |
| for (Cookie cookie : cookieArray) { | |
| if (key.equals(cookie.getName())) { | |
| return cookie.getValue(); | |
| } | |
| } | |
| } | |
| return NA; | |
| } |