harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [testing] Exception java.nio.channels.IllegalSelectorException thrown in dnsjava
Date Thu, 30 Oct 2008 17:03:17 GMT
Mark Gertsvolf wrote:
> I am running Harmony JVM 5.0 on CentOS 5, x86 and I am using dnsjava
> library. The following simple A lookup works as expected with IBM JVM
> 5.0 and results in exception with Harmony.
> 
> try {
> 	org.xbill.DNS.Record[] records = new
> org.xbill.DNS.Lookup("magma.ca").run();
> } catch (Throwable ex) {
> 	ex.printStackTrace();
> }
> 
> Exception:
> java.nio.channels.IllegalSelectorException
>         at
> java.nio.channels.spi.AbstractSelectableChannel.register(AbstractSelecta
> bleChannel.java:137)
>         at
> java.nio.channels.SelectableChannel.register(SelectableChannel.java:115)
>         at org.xbill.DNS.Client.<init>(Client.java:22)
>         at org.xbill.DNS.UDPClient.<init>(UDPClient.java:14)
>         at org.xbill.DNS.UDPClient.sendrecv(UDPClient.java:64)
>         at org.xbill.DNS.SimpleResolver.send(SimpleResolver.java:256)
>         at org.xbill.DNS.ResolveThread.run(ResolveThread.java:37)
> 
> I studied dnsjava code and I do not see any reason for
> IllegalSelectorException to be thrown. 
> http://dnsjava.cvs.sourceforge.net/viewvc/dnsjava/dnsjava/org/xbill/DNS/
> Client.java?revision=1.5&view=markup
> http://dnsjava.cvs.sourceforge.net/viewvc/dnsjava/dnsjava/org/xbill/DNS/
> UDPClient.java?revision=1.4&view=markup
> 
> 
> How does one troubleshoot this type of problem?
> Any help will be appreciated.

At the risk of sounding patronizing, "in a debugger" ;-)

In this case it would be possible to catch the IllegalSelectorException
and go in to look at how the program got there and the values of the
variables at the time.

I see that Client.java:23 is explicitly registering a selector with a
channel and giving an empty set of operations it is interested in, and
AbstractSelectableChannel.java:135 is throwing the exception if the set
is empty.

Here's a simple reproducer

    public static void main(String[] args) throws IOException {
        SocketChannel channel = SocketChannel.open();
        channel.configureBlocking(false);
        Selector selector = Selector.open();

        channel.register(selector, 0);
    }


I don't know why we forbid an empty set of interested operations?
If I remove the check my simple test above works...

Regards,
Tim




Mime
View raw message