From: markt Date: Tue, 9 Mar 2010 13:15:15 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48760 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c92e79ad873eb20d8a6b9628f3c8792429a5783c;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48760 Remove potential race condition that can result in multiple threads trying to use the same InputStream git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@920858 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/naming/resources/FileDirContext.java b/java/org/apache/naming/resources/FileDirContext.java index 9b556fe4e..6ef0d4e63 100644 --- a/java/org/apache/naming/resources/FileDirContext.java +++ b/java/org/apache/naming/resources/FileDirContext.java @@ -892,7 +892,7 @@ public class FileDirContext extends BaseDirContext { /** - * This specialized resource implementation avoids opening the IputStream + * This specialized resource implementation avoids opening the InputStream * to the file right away (which would put a lock on the file). */ protected class FileResource extends Resource { @@ -933,7 +933,9 @@ public class FileDirContext extends BaseDirContext { public InputStream streamContent() throws IOException { if (binaryContent == null) { - inputStream = new FileInputStream(file); + FileInputStream fis = new FileInputStream(file); + inputStream = fis; + return fis; } return super.streamContent(); } diff --git a/java/org/apache/naming/resources/WARDirContext.java b/java/org/apache/naming/resources/WARDirContext.java index 1c975b70d..4702b9501 100644 --- a/java/org/apache/naming/resources/WARDirContext.java +++ b/java/org/apache/naming/resources/WARDirContext.java @@ -979,7 +979,9 @@ public class WARDirContext extends BaseDirContext { throws IOException { try { if (binaryContent == null) { - inputStream = base.getInputStream(entry); + InputStream is = base.getInputStream(entry); + inputStream = is; + return is; } } catch (ZipException e) { throw new IOException(e.getMessage());