Submitted On 29-AUG-2002
amcconne
I have seen this issue intermittently as well on Linux with
1.4.1RC1. I *cannot* reproduce under Win2K w/JDK1.4.1RC1.
Submitted On 03-NOV-2002
ffdixon
Workaround:
I was able to reproduce this bug fairly consistently. It seems
to occur when other threads are closing socketChannels.
Under the right conditions, it triggers a NullPointerException in
the select() call.
In my case, the threads were closing the channels when the
output buffer was full. (i.e. a call to socketChannel.write
(buf) returned zero). Could this be relevant?
In any case, to avoid this bug, I added a queue to the
selector() thread. Now, when I wanted to close a
socketChannel, I add the socketChannel to the queue and
then call selector.wakeup(). This wakes up the thread
blocked on select() and it now reads off the SocketChannels
from the queue and closes them.
Having done this, I no longer see the NullPointerException.
Hope this helps. BTW, NIO rocks.
Regards,... Fred
Submitted On 03-NOV-2002
ffdixon
I am starting to get a similar error when multiple threads are
closing a socketChannel. My setup is J2SDK 1.4.1, Win 2K
(SP3).
Here's the error I get:
java.lang.NullPointerException
at
sun.nio.ch.WindowsSelectorImpl$SubSelector.processFdSet
(WindowsSelectorImpl.java:302)
at
sun.nio.ch.WindowsSelectorImpl$SubSelector.processSelected
Keys(WindowsSelectorImpl.java:280)
at
sun.nio.ch.WindowsSelectorImpl$SubSelector.access$2600
(WindowsSelectorImpl.java:244)
at
sun.nio.ch.WindowsSelectorImpl.updateSelectedKeys
(WindowsSelectorImpl.java:405)
at sun.nio.ch.WindowsSelectorImpl.doSelect
(WindowsSelectorImpl.java:141)
at sun.nio.ch.SelectorImpl.select
(SelectorImpl.java:62)
at sun.nio.ch.SelectorImpl.select
(SelectorImpl.java:67)
at com.openlava.sdk.Reactor.doSelect
(Reactor.java:163)
at com.openlava.sdk.Reactor.runReactor
(Reactor.java:146)
at com.openlava.sdk.Reactor$1.run(Reactor.java:75)
at java.lang.Thread.run(Thread.java:536)
Submitted On 05-NOV-2002
KewlJava
I agree with ffdixon. The best way to deal with this problem is
to wakeup() the Thread blocking on select() and have it close
() the SocketChannels.
Submitted On 06-JUN-2003
Niklas_Bergh
This happens on WinXP Pro SP1 with this version of the JVM too:
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
Submitted On 06-JUN-2003
Niklas_Bergh
Could it be possible to get a status update on this bug?
Submitted On 11-AUG-2003
fttzx
11-Aug-2003 17:24:02 (freenet.transport.
ReadSelectorLoop, read interface thread, ERROR):
Worked around Sun windows JVM 'select'-bug (Sun
BugId: 4729342), please update your JVM to a fixed
version if possible
with java -version
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed
mode)
on Windows XP [Version 5.1.2600]
Submitted On 13-SEP-2003
transit
Just had this happen on Linux (RH 9) with JDK 1.4.2:
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
Submitted On 10-OCT-2003
maffeis
I'm getting the NullPointerException on WinXP SP1,
JDK 1.4.2_01-b06
Submitted On 29-OCT-2003
tcowan
I'm seeing this with JDK build 1.4.2_02-b03 on Windows 2000.
Submitted On 04-NOV-2003
Niklas_Bergh
>The best way to deal with this problem is
>to wakeup() the Thread blocking on select() and have it
>close() the SocketChannels.
But.. close() might block and there is no guarantee for how
long it will to that.... which isn't very desireable in a
selector thread.
Submitted On 18-JAN-2004
klowtherjr
Not only that, but you may not be in control of the thread
that closes the underlying socket for the channel. The
best thing I can recommend is to wrap the select() call
tightly with try/catch blocks and ignore the Exceptions.
Preface the try/catch with a null check if you are really
worried about catching an unintended exception, which
should generally not be a problem.
Submitted On 28-JAN-2004
pfranzen
I'm getting both exceptions on Windows NT
Workstation with JDK 1.4.1_02.
Submitted On 30-JAN-2004
Marc_Schoenefeld
Java Version: 1.4.2_03-b02
read at 1075482570317
read at 1075482570317
read at 1075482570317
read at 1075482579120
read at 1075482579120
read at 1075482637293
Exception in thread "main"
java.nio.channels.CancelledKeyException
at sun.nio.ch.SelectionKeyImpl.ensureValid
(SelectionKeyImpl.java:55)
at sun.nio.ch.SelectionKeyImpl.readyOps
(SelectionKeyImpl.java:77)
at java.nio.channels.SelectionKey.isAcceptable
(SelectionKey.java:342)
at NIO_Test.main(NIO_Test.java:45)
Submitted On 25-FEB-2004
Niklas_Bergh
Status update?
Has anything happened towards fixing this since the 2002/8/9
date mentioned above?
Submitted On 08-MAR-2004
pkalpesh1
Same error with JDK 1.4.2 on HP 11i platform
The error I get is:
java.nio.channels.CancelledKeyException
at sun.nio.ch.SelectionKeyImpl.ensureValid
(SelectionKeyImpl.java:55)
at sun.nio.ch.SelectionKeyImpl.interestOps
(SelectionKeyImpl.java:59)
at
sun.nio.ch.SocketChannelImpl.translateReadyOps
(SocketChannelImpl.java:
668)
at
sun.nio.ch.SocketChannelImpl.translateAndSetReadyO
ps(SocketChannelImpl
.java:715)
at
sun.nio.ch.DevPollSelectorImpl.updateSelectedKeys
(DevPollSelectorImpl.
java:107)
at sun.nio.ch.DevPollSelectorImpl.doSelect
(DevPollSelectorImpl.java:75)
at sun.nio.ch.SelectorImpl.lockAndDoSelect
(SelectorImpl.java:59)
at sun.nio.ch.SelectorImpl.select
(SelectorImpl.java:70)
at sun.nio.ch.SelectorImpl.select
(SelectorImpl.java:74)
at
com.telcordia.xsm.gateway_moc.JMOCTcpServer.run
(JMOCTcpServer.java:170)
Submitted On 31-MAR-2004
tswain
Trap the exception and move on.
EXPECT null pointer exceptions unless you manage a shared lock.
(T)
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|