Package net.sf.basedb.util
Class StaticCache.LockSafeInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- net.sf.basedb.util.StaticCache.LockSafeInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- 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
Fields Modifier and Type Field Description private Cleaner.Cleanable
cleanable
private boolean
closed
private String
key
private StaticCache.State
state
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description LockSafeInputStream(InputStream in, StaticCache.LockEntry lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
String
toString()
-
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
state
private final StaticCache.State state
-
cleanable
private final Cleaner.Cleanable cleanable
-
key
private final String key
-
closed
private boolean closed
-
-
Constructor Detail
-
LockSafeInputStream
LockSafeInputStream(InputStream in, StaticCache.LockEntry lock)
-
-
Method Detail
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
-
-