New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround for classpath resource concurrent access issue #37
Conversation
getResourceAsStream() is not equivalent to getResource() + openStream(). In concurrent env. the former sometimes returns and already closed stream.
I'm sure that |
@ddekany tbh, I don't know. It looks like an issue with the I've spent some hours trying to find the root cause, but it's even very hard to reproduce. I haven't found a stable reproducer, only one which I need to run like 30 times and hope it fails :( |
…s (caused by bugs outside of FreeMarker) when loading resources included in the FreeMarker jar (see freemarker.template.utility.ClassUtil.getReasourceAsStream). Related to #37.
I have committed a bit more generic and hopefully a bit safer (or rather more backward compatible) fix against this. See: bd7498e. It will go into 2.3.27. Can you confirm that it works? If so, please also close this issue. Thanks for reporting this and showing a workaround! |
Thanks for the quick fix! I'll run our build and will report back. |
The fix is unfortunately not working in 100% of the cases, please see my comment for more details: bd7498e#commitcomment-24827266 |
…properties. Related to #37. Also, fixed bug where we didn't try to find TLD resources with the thread context class loader.
Ah, of course, it can also concurrently close the |
What Java version are you using though? There's a few JDK bug fix that addresses similar (even if not identical) issues, like: https://bugs.openjdk.java.net/browse/JDK-6947916. |
|
Ah, now I noticed the bug also mentions fix version 1.8.0_161. I could try with that version. If it works would you prefer to revert the workarounds? |
I just realize that those 1.8 versions (152 and 161) weren't even released yet... The referred 1.7 was released 9 months ago. Anyway, for now I would keep the workaround, at least in the 2.3.x line. |
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:
After applying the workaround we never saw that exception again (with several hundreds of builds).