public class NOPReopener extends Object implements IReopenChannel<FileChannel>
FileChannel
once it has been
closed. This is useful for simple things where you still want the reliability
guarantees of FileChannelUtility
.Constructor and Description |
---|
NOPReopener(FileChannel channel) |
NOPReopener(RandomAccessFile raf) |
Modifier and Type | Method and Description |
---|---|
FileChannel |
reopenChannel()
Transparently re-opens the
Channel if it is closed. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toString
public NOPReopener(FileChannel channel)
public NOPReopener(RandomAccessFile raf)
public FileChannel reopenChannel() throws IOException
IReopenChannel
Channel
if it is closed.
Note: Java will close the backing Channel
if a Thread
is
interrupted during an NIO operation.
Note: This method MUST NOT be invoked if the channel was closed by an
interrupt in the caller's thread. The caller can detect
this condition by a thrown ClosedByInterruptException
rather than
either an AsynchronousCloseException
or an
ClosedChannelException
. See FileChannelUtility
which
knows how to handle this.
Note: This method MUST synchronized so that concurrent operations do not
try to re-open the Channel
at the same time.
Note: While the Channel
may be open within the implementation of
this method, it IS NOT possible guaranteed that it will be open by the
time you try to use it except by synchronizing all activity on that
Channel
. In general, that will limit throughput.
Note: Platforms and volumes (such as NFS) which DO NOT support
FileLock
should re-open the file anyway without throwing an
exception. This behavior is required to run in those contexts.
reopenChannel
in interface IReopenChannel<FileChannel>
Channel
and never null
.IOException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.