harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-4212) [classlib][nio] deregistered channel.configureBlocking(true) throws IllegalBlockingModeException
Date Tue, 19 Jun 2007 18:26:26 GMT

     [ 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.


Mime
View raw message