GitHub user psiroky opened a pull request:
https://github.com/apache/incubator-freemarker/pull/37
Workaround for classpath resource concurrent access issue
getResourceAsStream() is not equivalent to getResource() + openStream().
In concurrent env. the former sometimes returns and already closed
stream.
This is a workaround for the following issue we are encountering when using
Freemarker for annotation processing in parallel maven build (-T). This is
unfortunately just a workaround and such is not ideal, so fell free to reject
this.
The stacktrace of the error:
```
18:44:24 [ERROR]
/home/jenkins/workspace/guvnor/upstream-repos/uberfire/uberfire-showcase/uberfire-client-webapp/src/main/java/org/uberfire/client/screens/DemoSplashScreen.java:[34,1]
Internal error in
org.uberfire.annotations.processors.WorkbenchSplashScreenProcessorjava.lang.ExceptionInInitializerError
18:44:24 [ERROR] at
org.uberfire.annotations.processors.AbstractGenerator.<init>(AbstractGenerator.java:44)
18:44:24 [ERROR] at
org.uberfire.annotations.processors.SplashScreenActivityGenerator.<init>(SplashScreenActivityGenerator.java:41)
18:44:24 [ERROR] at
org.uberfire.annotations.processors.WorkbenchSplashScreenProcessor.<init>(WorkbenchSplashScreenProcessor.java:49)
18:44:24 [ERROR] at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
....
18:44:24 [ERROR] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
18:44:24 [ERROR] at java.lang.Thread.run(Thread.java:745)
18:44:24 [ERROR] Caused by: java.lang.IllegalStateException: zip file closed
18:44:24 [ERROR] at java.util.zip.ZipFile.ensureOpen(ZipFile.java:669)
18:44:24 [ERROR] at java.util.zip.ZipFile.getEntry(ZipFile.java:309)
18:44:24 [ERROR] at java.util.jar.JarFile.getEntry(JarFile.java:240)
18:44:24 [ERROR] at
sun.net.www.protocol.jar.URLJarFile.getEntry(URLJarFile.java:128)
18:44:24 [ERROR] at
sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:132)
18:44:24 [ERROR] at
sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
18:44:24 [ERROR] at
java.net.URLClassLoader.getResourceAsStream(URLClassLoader.java:238)
18:44:24 [ERROR] at
freemarker.template.Configuration.<clinit>(Configuration.java:431)
```
After applying the workaround we never saw that exception again (with
several hundreds of builds).
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/psiroky/incubator-freemarker zip-file-closed
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-freemarker/pull/37.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #37
----
commit 3d0e5c503ecb81404638e918b6f3778aa3f77a6b
Author: Petr Široký <[email protected]>
Date: 2017-08-23T10:44:54Z
Workaround for classpath resource concurrent access issue
getResourceAsStream() is not equivalent to getResource() + openStream().
In concurrent env. the former sometimes returns and already closed
stream.
----
---