Hi all,
We were able to reproduce a OutOfMemory error when using AJP and the
Resources cachingAllowed=false directive.
It looks like a bug of AJP connector(s), as it does not occurs with
other HTTP connectors.
Could you confirm the behavior described below is indeed bug ? (if you
do, I'll create the issue on bugzilla)
To reproduce :
* Use latest tomcat 8.5 version (tested with Tomcat 8.5.40)
* Add an AJP connector to server.xml
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
* Add the following directive to context.xml :
<Resources cachingAllowed="false" />
* Create a large file in the samples webapp, for example :
cd webapps/examples
dd if=/dev/zero of=large.txt bs=1k count=2000000
* Start Tomcat with a 1024 mb heap size (JAVA_OPTS="-Xms1024m -Xmx1024m"
* Configure Apache HTTPD to use mod_proxy_ajp, or mod_jk (both will
have the same issue) [1]
* Start Apache HTTPD
* Download file through default HTTP connector
http://localhost:8080/examples/large.txt
--> OK
* Download file through Apache/AJP http://localhost/examples/large.txt
--> BUG : OutOfMemory error occurs
Exception in thread "ajp-nio-8009-exec-10"
java.lang.OutOfMemoryError: Java heap space
at
org.apache.catalina.webresources.FileResource.getContent(FileResource.java:207)
at
org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:992)
at
org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:438)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
...
Additionnal informations :
* The bug could be reproduced on both Linux/Windows
* Tested with latest OpenJDK 8.
Regards,
Olivier
[1] the HTTPD configuration :
* if using mod_proxy_ajp (sudo a2enmod proxy proxy_ajp)
ProxyPass / ajp://127.0.0.1:8009/
* if using mod_jk : (sudo a2enmod jk)
JkWorkerProperty worker.list=tomcat
JkWorkerProperty worker.tomcat.type=ajp13
JkWorkerProperty worker.tomcat.host=localhost
JkWorkerProperty worker.tomcat.port=8009
JkMount / tomcat
JkMount /* tomcat