Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessEvent cannot return cookies when Jetty Request is recycled #11

Open
marinedayo opened this issue Apr 19, 2024 · 2 comments
Open
Assignees
Milestone

Comments

@marinedayo
Copy link
Contributor

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.

public void prepareForDeferredProcessing() {
getRequestHeaderMap();
getRequestParameterMap();
getResponseHeaderMap();
getLocalPort();
getMethod();
getProtocol();
getRemoteAddr();
getRemoteHost();
getRemoteUser();
getRequestURI();
getRequestURL();
getServerName();
getTimeStamp();
getElapsedTime();
getStatusCode();
getContentLength();
getRequestContent();
getResponseContent();
copyAttributeMap();
}

@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;
}

@ceki
Copy link
Member

ceki commented Apr 27, 2024

Fixed in commit 8509ec2

@ceki ceki added this to the 2.0.2 milestone Apr 27, 2024
@ceki
Copy link
Member

ceki commented Apr 27, 2024

relates to #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants