[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] AbstractSelectableChannel.register() patch
From: |
Guilhem Lavaux |
Subject: |
[cp-patches] AbstractSelectableChannel.register() patch |
Date: |
Thu, 20 Oct 2005 21:34:34 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050322) |
Hi,
Here is a bug one of our user stumbled on. GNU Classpath is not behaving
the same way as the jdk relatively to the required state of a channel
while registering in a Selector. I'll add a mauve test adapted from the
following testcase soon.
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
public class testChan
{
static public void main(String args[]) throws Exception
{
SocketChannel sc = SocketChannel.open();
Socket s = sc.socket();
System.err.println("Connecting to lo:80");
s.connect(new InetSocketAddress("localhost", 80));
System.err.println("Opening selector");
Selector sel = Selector.open();
System.err.println("Configure blocking");
sc.configureBlocking(true);
System.err.println("registering");
sc.register(sel, SelectionKey.OP_READ, null);
}
}
The patch is simple.
Cheers,
Guilhem.
Changelog:
2005-10-20 Guilhem Lavaux <address@hidden>
* java/nio/channels/spi/AbstractSelectableChannel.java
(register): Throw IllegalBlockingModeException if the channel is
not in blocking mode.
Index: java/nio/channels/spi/AbstractSelectableChannel.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/java/nio/channels/spi/AbstractSelectableChannel.java,v
retrieving revision 1.18
diff -u -r1.18 AbstractSelectableChannel.java
--- java/nio/channels/spi/AbstractSelectableChannel.java 2 Jul 2005
20:32:40 -0000 1.18
+++ java/nio/channels/spi/AbstractSelectableChannel.java 20 Oct 2005
19:30:54 -0000
@@ -224,6 +224,9 @@
synchronized (blockingLock())
{
+ if (blocking)
+ throw new IllegalBlockingModeException();
+
key = locate(selector);
if (key != null && key.isValid())
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] AbstractSelectableChannel.register() patch,
Guilhem Lavaux <=