>From JavaDocs:
The state of a file channel is intimately connected to that of the object whose 
getChannel method returned the channel. Changing the channel's position, 
whether explicitly or by reading or writing bytes, will change the file 
position of the originating object, and vice versa. Changing the file's length 
via the file channel will change the length seen via the originating object, 
and vice versa. Changing the file's content by writing bytes will change the 
content seen by the originating object, and vice versa.

This can only work if the RandomAccessFile and the corresponding channel use 
the same descriptor. So if you create a RandomAccessFile in the ctor and call 
getChannel() later, just keep the RandomAccessFile open and close it at close. 

The current code uses File.openChannel().

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de


> -----Original Message-----
> From: Uwe Schindler [mailto:u...@thetaphi.de]
> Sent: Thursday, January 28, 2010 12:23 PM
> To: java-dev@lucene.apache.org
> Subject: RE: Nasty NIO behavior makes NIOFSDirectory silently close
> channel
> 
> I am not sure, because RandomAccessFile has a getChannel method, so I
> suspect that they share the descriptor. Maybe check it with lsof?
> 
> Possibly we could wait until Simon provides a testcase that fails.
> 
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: u...@thetaphi.de
> 
> 
> > -----Original Message-----
> > From: Michael McCandless [mailto:luc...@mikemccandless.com]
> > Sent: Thursday, January 28, 2010 12:08 PM
> > To: java-dev@lucene.apache.org
> > Subject: Re: Nasty NIO behavior makes NIOFSDirectory silently close
> > channel
> >
> > On Thu, Jan 28, 2010 at 5:59 AM, Uwe Schindler <u...@thetaphi.de>
> wrote:
> > > But if you keep the underlying RandomAccessFile open?
> >
> > We could do that but... won't this consume 2 file descriptors?
> >
> > Mike
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
> > For additional commands, e-mail: java-dev-h...@lucene.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-dev-h...@lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to