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

Streaming large Downloads without Content-length when using AJP produces OutOfMemory #21552

Closed
glassfishrobot opened this issue Jul 20, 2016 · 6 comments

Comments

@glassfishrobot
Copy link

When streaming large (> 100MB) downloads without Content-Length via mod_ajp to Apache, OutOfMemoryErrors occur.

Stacktrace:

java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3181)
at org.glassfish.grizzly.memory.BuffersBuffer.ensureBuffersCapacity(BuffersBuffer.java:303)
at org.glassfish.grizzly.memory.BuffersBuffer.append(BuffersBuffer.java:230)
at org.glassfish.grizzly.memory.BuffersBuffer.split(BuffersBuffer.java:463)
at org.glassfish.grizzly.http.ajp.AjpMessageUtils.appendContentAndTrim(AjpMessageUtils.java:486)
at org.glassfish.grizzly.http.ajp.AjpHandlerFilter.encodeHttpPacket(AjpHandlerFilter.java:275)
at org.glassfish.grizzly.http.ajp.AjpHandlerFilter.handleWrite(AjpHandlerFilter.java:244)
at org.glassfish.grizzly.filterchain.ExecutorResolver$8.execute(ExecutorResolver.java:111)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.filterchain.FilterChainContext.write(FilterChainContext.java:848)
at org.glassfish.grizzly.filterchain.FilterChainContext.write(FilterChainContext.java:817)
at org.glassfish.grizzly.http.io.OutputBuffer.flushBuffer(OutputBuffer.java:1024)
at org.glassfish.grizzly.http.io.OutputBuffer.flushBinaryBuffers(OutputBuffer.java:1011)
at org.glassfish.grizzly.http.io.OutputBuffer.flushAllBuffers(OutputBuffer.java:982)
at org.glassfish.grizzly.http.io.OutputBuffer.close(OutputBuffer.java:715)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:263)
at org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:186)
at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.destroy(ZipArchiveOutputStream.java:1426)
at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.close(ZipArchiveOutputStream.java:808)

The problem is also described here: payara/Payara#350

The fix provided in this issue https://java.net/jira/browse/GLASSFISH-21202 doesn't help here. The root cause for the problem is, that in the class AjpHttpRequest the chunking isn't enabled, therefore the response is buffered completely.

Affected Versions

[4.1]

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by unwichtich

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
unwichtich said:
Here is the relevant grizzly bug: https://java.net/jira/browse/GRIZZLY-1787

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
unwichtich said:
Here is a patched JAR which includes the required fix: https://dl.dropboxusercontent.com/u/6862316/so/glassfish-grizzly-extra-all.jar

The included change is very similar to this: https://github.com/GrizzlyNIO/grizzly-mirror/commit/6c08805499f7c6b64c3c8806a71f0b58b52c960b

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA GLASSFISH-21552

@glassfishrobot
Copy link
Author

@rlubke Commented
This issue has been addressed in later versions of Grizzly that has been integrated into GF5.

@glassfishrobot
Copy link
Author

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

1 participant