Bug 62976 - IllegalStateException: zip file closed
Summary: IllegalStateException: zip file closed
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 9.0.13
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-04 05:02 UTC by Karl von Randow
Modified: 2018-12-05 22:09 UTC (History)
0 users



Attachments
Test case reproducing the issue (366.50 KB, application/zip)
2018-12-04 05:02 UTC, Karl von Randow
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karl von Randow 2018-12-04 05:02:12 UTC
Created attachment 36290 [details]
Test case reproducing the issue

It appears that the bug https://bz.apache.org/bugzilla/show_bug.cgi?id=57887 has resurfaced in Tomcat 9.

The test case from that bug fails in Tomcat 9 with the error stack trace:

04-Dec-2018 17:57:06.353 SEVERE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.ApplicationContext.log Background compile failed
 java.lang.IllegalStateException: zip file closed
        at java.util.zip.ZipFile.ensureOpen(ZipFile.java:686)
        at java.util.zip.ZipFile.getEntry(ZipFile.java:315)
        at java.util.jar.JarFile.getEntry(JarFile.java:240)
        at org.apache.tomcat.util.scan.JarFileUrlJar.getLastModified(JarFileUrlJar.java:94)
        at org.apache.jasper.JspCompilationContext.getLastModified(JspCompilationContext.java:380)
        at org.apache.jasper.JspCompilationContext.getLastModified(JspCompilationContext.java:368)
        at org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:480)
        at org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:434)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:596)
        at org.apache.jasper.compiler.JspRuntimeContext.checkCompile(JspRuntimeContext.java:385)
        at org.apache.jasper.servlet.JspServlet.periodicEvent(JspServlet.java:357)
        at org.apache.catalina.core.StandardWrapper.backgroundProcess(StandardWrapper.java:623)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1398)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1402)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1402)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1402)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1370)
        at java.lang.Thread.run(Thread.java:748)

This appears to be due to the .tag file in the JAR.

I have inserted debugging into JarFileUrlJar and I can see that getLastModified is called successfully, close() is called, and then getLastModified is called again and fails as the zip is closed.

I have attached the same test case hoping it's easier that getting it from that bug. Make a WAR from the WebContent directory and deploy. Load the web app. Wait a minute.
Comment 1 Mark Thomas 2018-12-04 19:08:02 UTC
Note: To trigger this issue, development needs to be set to false and checkInterval set to a positive integer - 60 is a reasonable number in this instance.
Comment 2 Mark Thomas 2018-12-05 20:20:23 UTC
Thanks for the report and for spotting the link to the previous issue. Very helpful.

Fixed in:
- trunk for 9.0.14 onwards
- 8.5.x for 8.5.36 onwards
Comment 3 Karl von Randow 2018-12-05 22:09:13 UTC
Mark, thank you very much. Love your work.