Closed jonescc closed 6 years ago
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
jachope has signed the CLA for the organization, so we can ignore the CLA check.
Excellent - thank you for this fix!
This fixes https://github.com/Unidata/thredds/issues/1052 and other associated issues.
When serving a GetMap request and the client connection is closed prior to completing the response, javax.imageio.stream.MemoryCacheImageInputStream was not being closed properly due to a ClientAbortException being thrown when trying write to and then flush/close the stream (at http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/9d617cfd6717/src/share/classes/javax/imageio/ImageIO.java#l1580). This class has a finalizer inherited from one of its parent classes (http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/9d617cfd6717/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java#l871) which closes the stream if its still open. Finalizers are invoked some time later by the finalizer thread (essentially a random time later). Closing MemoryCacheImageInputStream closes its wrapped output stream (in this case the ServletOutputStream). Tomcat reuses ServletOutputStream instances and so this output stream may be being used by another request and being flushed/closed inappropriately during that processing.
This is a known issue with these core java classes and tomcat (refer http://mail-archives.apache.org/mod_mbox/tomcat-users/201306.mbox/%3C51B0B101.3060509@christopherschultz.net%3E and https://bugs.java.com/view_bug.do?bug_id=6299405) with the recommended solution included below.
We have been using this code in our production thredds instance now for almost 2 years with no issues and no "Yikes! Response is already committed (Heiko's bug?)" messages in the log.