We had an issue that prevented us from deleting certain JSPs in an embedded Tomcat. The cause of that seems to be that an InputStream is not closed after trying to figure out the encoding of a .jsp file. From our point of view this seems to affect at least Tomcat 8.5.16 with following classes involved: org.apache.jasper.compiler.ParserController: > 321: InputStream inStream = JspUtil.getInputStream(absFileName, jar, ctxt); > 322: EncodingDetector encodingDetector = new EncodingDetector(inStream); => The InputStream is retrieved and passed to the EncodingDetector. org.apache.jasper.compiler.EncodingDetector: > 96: XMLStreamReader xmlStreamReader = XML_INPUT_FACTORY.createXMLStreamReader(stream); => The EncodingDetector creates an XMLStreamReader on its static XML_INPUT_FACTORY. As a workaround we configured the JspConfig like this to prevent the detection of the encoding: > <jsp-config> > <jsp-property-group> > <url-pattern>*.jsp</url-pattern> > <is-xml>false</is-xml> > </jsp-property-group> > </jsp-config>
For anyone trying to reproduce this, you'll need to disable resource caching for the associated Context. It is also a lot easier to reproduce on Windows since Windows prevents deletion of locked files. This has been fixed in : - trunk for 9.0.0.M26 onwards - 8.5.x for 8.5.20 onwards Many thanks for the report and the analysis to pin-point the issue.