2.17.2: 2011-06-17

net.sf.basedb.util
Class StaticCache.LockSafeInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by net.sf.basedb.util.StaticCache.LockSafeInputStream
All Implemented Interfaces:
Closeable
Enclosing class:
StaticCache

static class StaticCache.LockSafeInputStream
extends FilterInputStream

A lock-safe input stream that releases the associated read lock when the stream is closed.

NOTE! It is important that we keep a strong reference to the 'key' in this class until the stream is closed, since otherwise the locked entry may be reclaimed by the garbage collector.


Field Summary
private  Throwable calledFrom
           
private  boolean closed
           
private  String key
           
private  ReadWriteLock lock
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
StaticCache.LockSafeInputStream(InputStream in, StaticCache.LockEntry lock)
           
 
Method Summary
 void close()
           
protected  void finalize()
           
 String toString()
           
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

calledFrom

private final Throwable calledFrom

lock

private ReadWriteLock lock

key

private String key

closed

private boolean closed
Constructor Detail

StaticCache.LockSafeInputStream

StaticCache.LockSafeInputStream(InputStream in,
                                StaticCache.LockEntry lock)
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class FilterInputStream
Throws:
IOException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

toString

public String toString()
Overrides:
toString in class Object

2.17.2: 2011-06-17