Bug 60410 - Stream closed when reading war entry
Summary: Stream closed when reading war entry
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.33
Hardware: PC Linux
: P2 critical (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-24 02:58 UTC by guoh0115
Modified: 2016-12-02 03:50 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description guoh0115 2016-11-24 02:58:46 UTC
When the application is deployed as "unpackWAR=false", sometimes I try to download a js file which is over than 2MB, ERR_CONTENT_LENGTH_MISMATCH will be thrown on the front end, I use Chrome.

I checked accesslog and found the file's content length is less than it is when the exception thrown.

Here's the stacktrace I found in the log file:

java.io.IOException: Stream closed
         at java.util.zip.InflaterInputStream.ensureOpen(InflaterInputStream.java:67)
         at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:142)
         at org.apache.catalina.webresources.AbstractArchiveResource$JarInputStreamWrapper.read(AbstractArchiveResource.java:255)
         at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
         at java.io.FilterInputStream.read(FilterInputStream.java:107)
         at org.apache.catalina.servlets.DefaultServlet.copyRange(DefaultServlet.java:2125)
         at org.apache.catalina.servlets.DefaultServlet.copy(DefaultServlet.java:1971)
         at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:968)
        at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:398)
Comment 1 Violeta Georgieva 2016-11-24 08:20:00 UTC
Hi,

Can you test with the latest Tomcat 8 version (8.0.39)?
Can you provide a simple example that reproduces the issue?
Do you see this problem with other browsers?


Thanks,
Violeta
Comment 2 guoh0115 2016-11-25 03:24:13 UTC
I usually take about 5-10s to download the js file, and the more time it took, the easier the error occured.

I cannot deploy on tomcat 8.0.39, here's the error log, do you have any idea?

org.apache.catalina.startup.ContextConfig.processServletContainerInitializers Failed to detect ServletContainerInitializers for context with name [/imsp]
 java.io.FileNotFoundException: JAR entry !/META-INF/services/javax.servlet.ServletContainerInitializer not found in D:\apache-tomcat-8.0.39\temp\jar_cache4125440539893731259.tmp
	at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:140)
	at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
	at java.net.URL.openStream(URL.java:1037)
	at org.apache.catalina.startup.WebappServiceLoader.parseConfigFile(WebappServiceLoader.java:162)
	at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:136)
	at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1631)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1140)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:783)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:744)
Comment 3 guoh0115 2016-11-25 03:28:33 UTC
I only changed unpackWARs to false in server.xml.

 <Host name="localhost"  appBase="webapps"
            unpackWARs="false" autoDeploy="true">
Comment 4 guoh0115 2016-11-25 04:00:56 UTC
I debuged, spring-web-4.2.5.RELEASE.jar is in our app. so tomcat cannot load /META-INF/services/javax.servlet.ServletContainerInitializer from the jar file when unpackWAR=false
Comment 5 Mark Thomas 2016-11-26 09:50:41 UTC
I've fixed the issue that prevents SCIs from being processed with 8.0.39. The fix will be in 8.0.40 onwards. You'll need to build 8.0.x from source (not as difficuly as you might think) to test it.

I'm still looking for possible causes of the original problem.
Comment 6 Mark Thomas 2016-11-27 18:40:10 UTC
I've found the likely cause. If close is called multiple times on a JarInputStreamWrapper then it is possible that this error could occur. I should have a fix for this shortly.
Comment 7 Mark Thomas 2016-11-28 11:16:16 UTC
Fixed in:
- trunk for 9.0.0.M14 onwards
- 8.5.x for 8.5.9 onwards
- 8.0.x for 8.0.40 onwards

7.0.x and earlier was not affected.
Comment 8 guoh0115 2016-12-02 03:50:56 UTC
When will it be released?