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
/**
- * 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 {
public InputStream streamContent()
throws IOException {
if (binaryContent == null) {
- inputStream = new FileInputStream(file);
+ FileInputStream fis = new FileInputStream(file);
+ inputStream = fis;
+ return fis;
}
return super.streamContent();
}
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());