classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NIO Channel Synchronization bugs


From: David Holmes
Subject: NIO Channel Synchronization bugs
Date: Wed, 14 Apr 2004 12:03:39 +1000

I'm having trouble with my savannah account at present and so can't submit a
bug report.

Looking at some of the java.nio.channel classes I'm seeing incorrectly
synchronized code:

AbstractSelectableChannel: boolean blocking

This field is set under synchronization but isBlocking() reads it without
synchronization. Either isBlocking() needs to synchronize on the
blockingLock() object, or else blocking needs to be volatile


AbstractInterruptibleChannel: boolean closed

This is field is both set (close()) and read (isOpen()) without any
synchronization. At a minimum this field should be volatile.

Note that close() as it stands allows for implCloseChannel to be invoked
concurrently by more than one thread. Hence implCloseChannel will have to be
written to deal with that correctly.

gnu.java.nio.channels.FileChannelImpl

This class contains lots of methods of the form:

  if (!isOpen()) throw ClosedChannelException();
  // proceed with operation

but there seems to be no synchronization that prevents the channel from
being closed the moment after isOpen is checked. Am I to assume that all the
implXXX and other native methods have responsibility for dealing with this?
And for dealing with concurrent invocations?


There may be others but that was all I saw while browsing for other things.

Cheers,
David Holmes





reply via email to

[Prev in Thread] Current Thread [Next in Thread]