You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Sergey Dmitriev (JIRA)" <ji...@apache.org> on 2007/06/18 11:48:26 UTC

[jira] Created: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException

[classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
------------------------------------------------------------------------------------------------

                 Key: HARMONY-4212
                 URL: https://issues.apache.org/jira/browse/HARMONY-4212
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Sergey Dmitriev


In nio.channels: after deregistering and removing SocketChannel from selector calling channel.configureBlocking(true) throws IllegalBlockingModeException. Actually this not how it is have to be. Please see the mini test. (Please execute "telnet localhost 9999" in other shell after test launch).

] guy@box ~
] cat select7.java
import java.nio.channels.*;
import java.net.*;
import java.util.*;

public class select7 {

    public static void main(String[] args) throws Exception {

        Selector selector = Selector.open();
        ServerSocketChannel ssc = ServerSocketChannel.open();
        ssc.socket().bind(new InetSocketAddress(9999));


        // server listening

        System.out.println("Waiting on accept...");
        SocketChannel sc = ssc.accept();
        System.out.println("Done.");


        // register & select

        sc.configureBlocking(false);
        sc.register(selector, SelectionKey.OP_READ);
        System.out.println("Waiting on select()...");
        int res = selector.select();
        System.out.println("Done. " + res + " key(s) up.");


        // run through the selected keys

        Iterator readyKeys = selector.selectedKeys().iterator();
        while (readyKeys.hasNext()) {
            SelectionKey key = (SelectionKey)readyKeys.next();
            System.out.println("Selected key = " + key);
            key.cancel();
            readyKeys.remove();
            SelectableChannel ch = key.channel();
            ch.configureBlocking(true);
        }
    }
}



] guy@box ~
] ~/jre2/bin/java -showversion select7
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r540000, (May 21 2007), Linux/ia32/gcc 3.3.3, release build
http://incubator.apache.org/harmony
Waiting on accept...
Done.
Waiting on select()...
Done. 1 key(s) up.
Selected key = org.apache.harmony.nio.internal.SelectionKeyImpl@4507d7e0
Uncaught exception in main:
java.nio.channels.IllegalBlockingModeException
        at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:206)
        at select7.main(select7.java:39)



] guy@box ~
] java -showversion select7
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
BEA JRockit(R) (build R26.3.0-32-58710-1.5.0_06-20060308-2022-linux-ia32, )

Waiting on accept...
Done.
Waiting on select()...
Done. 1 key(s) up.
Selected key = sun.nio.ch.SelectionKeyImpl@10e847b


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-4212:
----------------------------------------

    Assignee: Alexei Zakharov

> [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4212
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4212
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sergey Dmitriev
>            Assignee: Alexei Zakharov
>         Attachments: 4212workaround.patch, H-4212.patch
>
>
> In nio.channels: after deregistering and removing SocketChannel from selector calling channel.configureBlocking(true) throws IllegalBlockingModeException. Actually this not how it is have to be. Please see the mini test. (Please execute "telnet localhost 9999" in other shell after test launch).
> ] guy@box ~
> ] cat select7.java
> import java.nio.channels.*;
> import java.net.*;
> import java.util.*;
> public class select7 {
>     public static void main(String[] args) throws Exception {
>         Selector selector = Selector.open();
>         ServerSocketChannel ssc = ServerSocketChannel.open();
>         ssc.socket().bind(new InetSocketAddress(9999));
>         // server listening
>         System.out.println("Waiting on accept...");
>         SocketChannel sc = ssc.accept();
>         System.out.println("Done.");
>         // register & select
>         sc.configureBlocking(false);
>         sc.register(selector, SelectionKey.OP_READ);
>         System.out.println("Waiting on select()...");
>         int res = selector.select();
>         System.out.println("Done. " + res + " key(s) up.");
>         // run through the selected keys
>         Iterator readyKeys = selector.selectedKeys().iterator();
>         while (readyKeys.hasNext()) {
>             SelectionKey key = (SelectionKey)readyKeys.next();
>             System.out.println("Selected key = " + key);
>             key.cancel();
>             readyKeys.remove();
>             SelectableChannel ch = key.channel();
>             ch.configureBlocking(true);
>         }
>     }
> }
> ] guy@box ~
> ] ~/jre2/bin/java -showversion select7
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r540000, (May 21 2007), Linux/ia32/gcc 3.3.3, release build
> http://incubator.apache.org/harmony
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = org.apache.harmony.nio.internal.SelectionKeyImpl@4507d7e0
> Uncaught exception in main:
> java.nio.channels.IllegalBlockingModeException
>         at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:206)
>         at select7.main(select7.java:39)
> ] guy@box ~
> ] java -showversion select7
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> BEA JRockit(R) (build R26.3.0-32-58710-1.5.0_06-20060308-2022-linux-ia32, )
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = sun.nio.ch.SelectionKeyImpl@10e847b

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException

Posted by "Sergey Dmitriev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506852 ] 

Sergey Dmitriev commented on HARMONY-4212:
------------------------------------------

I confirm that now OC4J runs smoothly. Thanks for you work!

> [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4212
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4212
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sergey Dmitriev
>            Assignee: Alexei Zakharov
>         Attachments: 4212workaround.patch, H-4212.patch
>
>
> In nio.channels: after deregistering and removing SocketChannel from selector calling channel.configureBlocking(true) throws IllegalBlockingModeException. Actually this not how it is have to be. Please see the mini test. (Please execute "telnet localhost 9999" in other shell after test launch).
> ] guy@box ~
> ] cat select7.java
> import java.nio.channels.*;
> import java.net.*;
> import java.util.*;
> public class select7 {
>     public static void main(String[] args) throws Exception {
>         Selector selector = Selector.open();
>         ServerSocketChannel ssc = ServerSocketChannel.open();
>         ssc.socket().bind(new InetSocketAddress(9999));
>         // server listening
>         System.out.println("Waiting on accept...");
>         SocketChannel sc = ssc.accept();
>         System.out.println("Done.");
>         // register & select
>         sc.configureBlocking(false);
>         sc.register(selector, SelectionKey.OP_READ);
>         System.out.println("Waiting on select()...");
>         int res = selector.select();
>         System.out.println("Done. " + res + " key(s) up.");
>         // run through the selected keys
>         Iterator readyKeys = selector.selectedKeys().iterator();
>         while (readyKeys.hasNext()) {
>             SelectionKey key = (SelectionKey)readyKeys.next();
>             System.out.println("Selected key = " + key);
>             key.cancel();
>             readyKeys.remove();
>             SelectableChannel ch = key.channel();
>             ch.configureBlocking(true);
>         }
>     }
> }
> ] guy@box ~
> ] ~/jre2/bin/java -showversion select7
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r540000, (May 21 2007), Linux/ia32/gcc 3.3.3, release build
> http://incubator.apache.org/harmony
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = org.apache.harmony.nio.internal.SelectionKeyImpl@4507d7e0
> Uncaught exception in main:
> java.nio.channels.IllegalBlockingModeException
>         at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:206)
>         at select7.main(select7.java:39)
> ] guy@box ~
> ] java -showversion select7
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> BEA JRockit(R) (build R26.3.0-32-58710-1.5.0_06-20060308-2022-linux-ia32, )
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = sun.nio.ch.SelectionKeyImpl@10e847b

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov closed HARMONY-4212.
------------------------------------


Issue closed.

> [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4212
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4212
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sergey Dmitriev
>            Assignee: Alexei Zakharov
>         Attachments: 4212workaround.patch, H-4212.patch
>
>
> In nio.channels: after deregistering and removing SocketChannel from selector calling channel.configureBlocking(true) throws IllegalBlockingModeException. Actually this not how it is have to be. Please see the mini test. (Please execute "telnet localhost 9999" in other shell after test launch).
> ] guy@box ~
> ] cat select7.java
> import java.nio.channels.*;
> import java.net.*;
> import java.util.*;
> public class select7 {
>     public static void main(String[] args) throws Exception {
>         Selector selector = Selector.open();
>         ServerSocketChannel ssc = ServerSocketChannel.open();
>         ssc.socket().bind(new InetSocketAddress(9999));
>         // server listening
>         System.out.println("Waiting on accept...");
>         SocketChannel sc = ssc.accept();
>         System.out.println("Done.");
>         // register & select
>         sc.configureBlocking(false);
>         sc.register(selector, SelectionKey.OP_READ);
>         System.out.println("Waiting on select()...");
>         int res = selector.select();
>         System.out.println("Done. " + res + " key(s) up.");
>         // run through the selected keys
>         Iterator readyKeys = selector.selectedKeys().iterator();
>         while (readyKeys.hasNext()) {
>             SelectionKey key = (SelectionKey)readyKeys.next();
>             System.out.println("Selected key = " + key);
>             key.cancel();
>             readyKeys.remove();
>             SelectableChannel ch = key.channel();
>             ch.configureBlocking(true);
>         }
>     }
> }
> ] guy@box ~
> ] ~/jre2/bin/java -showversion select7
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r540000, (May 21 2007), Linux/ia32/gcc 3.3.3, release build
> http://incubator.apache.org/harmony
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = org.apache.harmony.nio.internal.SelectionKeyImpl@4507d7e0
> Uncaught exception in main:
> java.nio.channels.IllegalBlockingModeException
>         at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:206)
>         at select7.main(select7.java:39)
> ] guy@box ~
> ] java -showversion select7
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> BEA JRockit(R) (build R26.3.0-32-58710-1.5.0_06-20060308-2022-linux-ia32, )
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = sun.nio.ch.SelectionKeyImpl@10e847b

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-4212:
------------------------------------

    Attachment: H-4212.patch

Here is the patch fixing the problem. It fixes the problem with the given test and i hope it'll fix the original problem with OC4J.

Fix description: API spec for configureBlocking() method says: "If this channel is registered with one or more selectors then an attempt to place it into blocking mode will cause an IllegalBlockingModeException to be thrown." On the other hand the spec for isRegistered() method says: "Due to the inherent delay between key cancellation and channel deregistration, a channel may remain registered for some time after all of its keys have been cancelled. A channel may also remain registered for some time after it is closed.". From this point of view isRegistered() method does not always provide correct information. So, as the keys are removed from the keyList "lazily" (i.e. after next select operation) the only way to understand if the keys was really cancelled is asking them directly. For example if we add in the given select7 code before calling configureBlocking() method these lines:
Selector sel = key.selector();
sel.select(100);
then the test passes without the patch.

> [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4212
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4212
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sergey Dmitriev
>         Attachments: 4212workaround.patch, H-4212.patch
>
>
> In nio.channels: after deregistering and removing SocketChannel from selector calling channel.configureBlocking(true) throws IllegalBlockingModeException. Actually this not how it is have to be. Please see the mini test. (Please execute "telnet localhost 9999" in other shell after test launch).
> ] guy@box ~
> ] cat select7.java
> import java.nio.channels.*;
> import java.net.*;
> import java.util.*;
> public class select7 {
>     public static void main(String[] args) throws Exception {
>         Selector selector = Selector.open();
>         ServerSocketChannel ssc = ServerSocketChannel.open();
>         ssc.socket().bind(new InetSocketAddress(9999));
>         // server listening
>         System.out.println("Waiting on accept...");
>         SocketChannel sc = ssc.accept();
>         System.out.println("Done.");
>         // register & select
>         sc.configureBlocking(false);
>         sc.register(selector, SelectionKey.OP_READ);
>         System.out.println("Waiting on select()...");
>         int res = selector.select();
>         System.out.println("Done. " + res + " key(s) up.");
>         // run through the selected keys
>         Iterator readyKeys = selector.selectedKeys().iterator();
>         while (readyKeys.hasNext()) {
>             SelectionKey key = (SelectionKey)readyKeys.next();
>             System.out.println("Selected key = " + key);
>             key.cancel();
>             readyKeys.remove();
>             SelectableChannel ch = key.channel();
>             ch.configureBlocking(true);
>         }
>     }
> }
> ] guy@box ~
> ] ~/jre2/bin/java -showversion select7
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r540000, (May 21 2007), Linux/ia32/gcc 3.3.3, release build
> http://incubator.apache.org/harmony
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = org.apache.harmony.nio.internal.SelectionKeyImpl@4507d7e0
> Uncaught exception in main:
> java.nio.channels.IllegalBlockingModeException
>         at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:206)
>         at select7.main(select7.java:39)
> ] guy@box ~
> ] java -showversion select7
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> BEA JRockit(R) (build R26.3.0-32-58710-1.5.0_06-20060308-2022-linux-ia32, )
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = sun.nio.ch.SelectionKeyImpl@10e847b

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-4212.
--------------------------------------

    Resolution: Fixed

Thanks gentlemen, Mikhail's patch was applied at the revision 549100. Please verify it was applied as expected and solves the original problem.

> [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4212
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4212
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sergey Dmitriev
>            Assignee: Alexei Zakharov
>         Attachments: 4212workaround.patch, H-4212.patch
>
>
> In nio.channels: after deregistering and removing SocketChannel from selector calling channel.configureBlocking(true) throws IllegalBlockingModeException. Actually this not how it is have to be. Please see the mini test. (Please execute "telnet localhost 9999" in other shell after test launch).
> ] guy@box ~
> ] cat select7.java
> import java.nio.channels.*;
> import java.net.*;
> import java.util.*;
> public class select7 {
>     public static void main(String[] args) throws Exception {
>         Selector selector = Selector.open();
>         ServerSocketChannel ssc = ServerSocketChannel.open();
>         ssc.socket().bind(new InetSocketAddress(9999));
>         // server listening
>         System.out.println("Waiting on accept...");
>         SocketChannel sc = ssc.accept();
>         System.out.println("Done.");
>         // register & select
>         sc.configureBlocking(false);
>         sc.register(selector, SelectionKey.OP_READ);
>         System.out.println("Waiting on select()...");
>         int res = selector.select();
>         System.out.println("Done. " + res + " key(s) up.");
>         // run through the selected keys
>         Iterator readyKeys = selector.selectedKeys().iterator();
>         while (readyKeys.hasNext()) {
>             SelectionKey key = (SelectionKey)readyKeys.next();
>             System.out.println("Selected key = " + key);
>             key.cancel();
>             readyKeys.remove();
>             SelectableChannel ch = key.channel();
>             ch.configureBlocking(true);
>         }
>     }
> }
> ] guy@box ~
> ] ~/jre2/bin/java -showversion select7
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r540000, (May 21 2007), Linux/ia32/gcc 3.3.3, release build
> http://incubator.apache.org/harmony
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = org.apache.harmony.nio.internal.SelectionKeyImpl@4507d7e0
> Uncaught exception in main:
> java.nio.channels.IllegalBlockingModeException
>         at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:206)
>         at select7.main(select7.java:39)
> ] guy@box ~
> ] java -showversion select7
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> BEA JRockit(R) (build R26.3.0-32-58710-1.5.0_06-20060308-2022-linux-ia32, )
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = sun.nio.ch.SelectionKeyImpl@10e847b

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506562 ] 

Mikhail Markov commented on HARMONY-4212:
-----------------------------------------

Thanks, Alexei - the patch is applied as expected.
Waiting for confirmation from Sergey about OC4J.

> [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4212
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4212
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sergey Dmitriev
>            Assignee: Alexei Zakharov
>         Attachments: 4212workaround.patch, H-4212.patch
>
>
> In nio.channels: after deregistering and removing SocketChannel from selector calling channel.configureBlocking(true) throws IllegalBlockingModeException. Actually this not how it is have to be. Please see the mini test. (Please execute "telnet localhost 9999" in other shell after test launch).
> ] guy@box ~
> ] cat select7.java
> import java.nio.channels.*;
> import java.net.*;
> import java.util.*;
> public class select7 {
>     public static void main(String[] args) throws Exception {
>         Selector selector = Selector.open();
>         ServerSocketChannel ssc = ServerSocketChannel.open();
>         ssc.socket().bind(new InetSocketAddress(9999));
>         // server listening
>         System.out.println("Waiting on accept...");
>         SocketChannel sc = ssc.accept();
>         System.out.println("Done.");
>         // register & select
>         sc.configureBlocking(false);
>         sc.register(selector, SelectionKey.OP_READ);
>         System.out.println("Waiting on select()...");
>         int res = selector.select();
>         System.out.println("Done. " + res + " key(s) up.");
>         // run through the selected keys
>         Iterator readyKeys = selector.selectedKeys().iterator();
>         while (readyKeys.hasNext()) {
>             SelectionKey key = (SelectionKey)readyKeys.next();
>             System.out.println("Selected key = " + key);
>             key.cancel();
>             readyKeys.remove();
>             SelectableChannel ch = key.channel();
>             ch.configureBlocking(true);
>         }
>     }
> }
> ] guy@box ~
> ] ~/jre2/bin/java -showversion select7
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r540000, (May 21 2007), Linux/ia32/gcc 3.3.3, release build
> http://incubator.apache.org/harmony
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = org.apache.harmony.nio.internal.SelectionKeyImpl@4507d7e0
> Uncaught exception in main:
> java.nio.channels.IllegalBlockingModeException
>         at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:206)
>         at select7.main(select7.java:39)
> ] guy@box ~
> ] java -showversion select7
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> BEA JRockit(R) (build R26.3.0-32-58710-1.5.0_06-20060308-2022-linux-ia32, )
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = sun.nio.ch.SelectionKeyImpl@10e847b

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException

Posted by "Sergey Dmitriev (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Dmitriev updated HARMONY-4212:
-------------------------------------

    Attachment: 4212workaround.patch

The 4212workaround.patch is not a fix but kind of dirty fix to make it possible to pass the provided testcase (select7.java) and to enable Oracle OC4J execution. Please treat it as this.

> [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4212
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4212
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sergey Dmitriev
>         Attachments: 4212workaround.patch
>
>
> In nio.channels: after deregistering and removing SocketChannel from selector calling channel.configureBlocking(true) throws IllegalBlockingModeException. Actually this not how it is have to be. Please see the mini test. (Please execute "telnet localhost 9999" in other shell after test launch).
> ] guy@box ~
> ] cat select7.java
> import java.nio.channels.*;
> import java.net.*;
> import java.util.*;
> public class select7 {
>     public static void main(String[] args) throws Exception {
>         Selector selector = Selector.open();
>         ServerSocketChannel ssc = ServerSocketChannel.open();
>         ssc.socket().bind(new InetSocketAddress(9999));
>         // server listening
>         System.out.println("Waiting on accept...");
>         SocketChannel sc = ssc.accept();
>         System.out.println("Done.");
>         // register & select
>         sc.configureBlocking(false);
>         sc.register(selector, SelectionKey.OP_READ);
>         System.out.println("Waiting on select()...");
>         int res = selector.select();
>         System.out.println("Done. " + res + " key(s) up.");
>         // run through the selected keys
>         Iterator readyKeys = selector.selectedKeys().iterator();
>         while (readyKeys.hasNext()) {
>             SelectionKey key = (SelectionKey)readyKeys.next();
>             System.out.println("Selected key = " + key);
>             key.cancel();
>             readyKeys.remove();
>             SelectableChannel ch = key.channel();
>             ch.configureBlocking(true);
>         }
>     }
> }
> ] guy@box ~
> ] ~/jre2/bin/java -showversion select7
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r540000, (May 21 2007), Linux/ia32/gcc 3.3.3, release build
> http://incubator.apache.org/harmony
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = org.apache.harmony.nio.internal.SelectionKeyImpl@4507d7e0
> Uncaught exception in main:
> java.nio.channels.IllegalBlockingModeException
>         at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:206)
>         at select7.main(select7.java:39)
> ] guy@box ~
> ] java -showversion select7
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> BEA JRockit(R) (build R26.3.0-32-58710-1.5.0_06-20060308-2022-linux-ia32, )
> Waiting on accept...
> Done.
> Waiting on select()...
> Done. 1 key(s) up.
> Selected key = sun.nio.ch.SelectionKeyImpl@10e847b

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.