Package net.sf.basedb.util
Class StaticCache.LockSafeOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- net.sf.basedb.util.StaticCache.LockSafeOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Enclosing class:
- StaticCache
static class StaticCache.LockSafeOutputStream extends FilterOutputStream
A lock-safe output stream that releases the associated write 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 Throwable
calledFrom
private boolean
closed
private String
key
private ReadWriteLock
lock
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description LockSafeOutputStream(OutputStream out, StaticCache.LockEntry lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected void
finalize()
String
toString()
-
Methods inherited from class java.io.FilterOutputStream
flush, write, write, write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Field Detail
-
calledFrom
private final Throwable calledFrom
-
lock
private ReadWriteLock lock
-
key
private String key
-
closed
private boolean closed
-
-
Constructor Detail
-
LockSafeOutputStream
LockSafeOutputStream(OutputStream out, StaticCache.LockEntry lock)
-
-
Method Detail
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
finalize
protected void finalize() throws Throwable
-
-