Skip to content
Browse files

Do nothing on close if there was no demand for the stream.

  • Loading branch information...
1 parent 7b9ddd6 commit 719b66d1d08c747a93fa31284d101f3ec87f470d @alesj alesj committed May 10, 2010
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/main/java/org/jboss/vfs/util/LazyInputStream.java
View
9 src/main/java/org/jboss/vfs/util/LazyInputStream.java
@@ -33,6 +33,9 @@
* Delaying opening stream from underlying virtual file as long as possible.
* Won't be opened if not used at all.
*
+ * Synchronization is very simplistic, as it's highly unlikely
+ * there will be a lot of concurrent requests.
+ *
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public class LazyInputStream extends InputStream
@@ -91,9 +94,13 @@ public int available() throws IOException
}
@Override
- public void close() throws IOException
+ public synchronized void close() throws IOException
{
+ if (stream == null)
+ return;
+
openStream().close();
+ stream = null; // reset the stream
}
@Override

0 comments on commit 719b66d

Please sign in to comment.
Something went wrong with that request. Please try again.