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

[UNDERTOW-1722] Resolve memory leak involving request attributes #942

Merged
merged 2 commits into from Aug 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -682,25 +682,33 @@ public ServletInputStream getInputStream() throws IOException {
}

public void closeAndDrainRequest() throws IOException {
if(reader != null) {
reader.close();
}
if(servletInputStream == null) {
servletInputStream = new ServletInputStreamImpl(this);
try {
if (reader != null) {
reader.close();
}
if (servletInputStream == null) {
servletInputStream = new ServletInputStreamImpl(this);
}
servletInputStream.close();
} finally {
clearAttributes();
}
servletInputStream.close();
}

/**
* Frees any resources (namely buffers) that may be associated with this request.
*
*/
public void freeResources() throws IOException {
if(reader != null) {
reader.close();
}
if(servletInputStream != null) {
servletInputStream.close();
try {
if(reader != null) {
reader.close();
}
if(servletInputStream != null) {
servletInputStream.close();
}
} finally {
clearAttributes();
}
}

Expand Down Expand Up @@ -1188,6 +1196,12 @@ public String toString() {
return "HttpServletRequestImpl [ " + getMethod() + ' ' + getRequestURI() + " ]";
}

public void clearAttributes() {
if(attributes != null) {
this.attributes.clear();
}
}

@Override
public PushBuilder newPushBuilder() {
if(exchange.getConnection().isPushSupported()) {
Expand Down