Author: markt
Date: Tue Mar 9 13:15:15 2010
New Revision: 920858
URL: http://svn.apache.org/viewvc?rev=920858&view=rev
Log:
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
Modified:
tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java
tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java
Modified: tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java?rev=920858&r1=920857&r2=920858&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java Tue Mar
9 13:15:15 2010
@@ -892,7 +892,7 @@ public class FileDirContext extends Base
/**
- * 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 Base
public InputStream streamContent()
throws IOException {
if (binaryContent == null) {
- inputStream = new FileInputStream(file);
+ FileInputStream fis = new FileInputStream(file);
+ inputStream = fis;
+ return fis;
}
return super.streamContent();
}
Modified: tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java?rev=920858&r1=920857&r2=920858&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java Tue Mar 9
13:15:15 2010
@@ -979,7 +979,9 @@ public class WARDirContext extends BaseD
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());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]