Skip to content

Commit

Permalink
Do nothing on close if there was no demand for the stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
alesj committed May 10, 2010
1 parent 7b9ddd6 commit 719b66d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/org/jboss/vfs/util/LazyInputStream.java
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 719b66d

Please sign in to comment.