This is an automated email from the ASF dual-hosted git repository. danwatford pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push: new c9ee842 Fixed: Issue starting ofbiz from tar distribution (OFBIZ-12118) c9ee842 is described below commit c9ee8421639a9d9b623d012531d76eddce1dcb48 Author: Daniel Watford <dan...@watfordconsulting.com> AuthorDate: Mon Jan 11 17:35:07 2021 +0000 Fixed: Issue starting ofbiz from tar distribution (OFBIZ-12118) Avoid using caches when opening a URL connection to read an XML resource in a JAR file. If caches were used when running from the ofbiz.jar file then attempts to read resources from the jar would fail due to the cached file's InputStream already being in a closed state. Thanks: Eugen Stan for the bug report and fix. --- .../base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java index 8e942c5..3d001d6 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java @@ -29,6 +29,7 @@ import java.io.OutputStream; import java.io.Reader; import java.io.Writer; import java.net.URL; +import java.net.URLConnection; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -379,7 +380,12 @@ public final class UtilXml { Debug.logWarning("[UtilXml.readXmlDocument] URL was null, doing nothing", MODULE); return null; } - try (InputStream is = url.openStream()) { + + URLConnection connection = url.openConnection(); + // OFBIZ-12118: Ensure caching is disabled otherwise we may find another thread has already closed the + // underlying file's InputStream when dealing with URLs to JAR resources. + connection.setUseCaches(false); + try (InputStream is = connection.getInputStream()) { return readXmlDocument(is, validate, url.toString()); } }