Mikhail Fursov wrote:
If API says (from the forst message message):
"If this channel was not created by the same provider as the given selector"
then the way you create the channel but not provider is important.
?


Yes, I'd like to know the difference between channels "created by provider" and "contain the same provider". My only thought was that RI may check stick if the class are written by their guys, e.g, see if they have the same class package. However does it make sense? I suggest Harmony keep it as it is until we have a meaningful idea about this.
Any comments?

On 7/27/06, Andrew Zhang <[EMAIL PROTECTED]> wrote:

On 7/27/06, Paulex Yang <[EMAIL PROTECTED]> wrote:
>
> Andrew Zhang wrote:
> > Seems strange.
> >
> > Following test fails against RI.
> >
> > The spec of SelectableChannel.register() says:
"IllegalSelectorExceptoin
> > -- If this channel was not created by the same provider as the given
> > selector".
> Same instance or same SelectorProvider subclass?


I think it's same instance. As you may notice, I use "assertSame(
channel.provider(), selector.provider());" in the test.

RI passes this assert statement and fails at channel.register(...) because
of IllegalSelectorException.

That's why I think RI is illogical in this case.

Any comments?

>
> > I suggest follow spec for this case. Thanks!
> >
> > public void test_channel() throws Exception {
> >        SelectorProvider provider = SelectorProvider.provider();
> >        Selector selector = Selector.open();
> >        MockChannel channel = new MockChannel(provider);
> >        channel.configureBlocking(false);
> >        assertSame(channel.provider(), selector.provider());
> > // test fails here against RI, IllegalSelectorException is thrown
> >        channel.register(selector, SelectionKey.OP_READ);
> >        selector.select();
> >    }
> >
> > class MockChannel extends SocketChannel {
> >
> >    protected MockChannel(SelectorProvider arg0) {
> >        super(arg0);
> >    }
> >
> >    public Socket socket() {
> >        return null;
> >    }
> >
> >    public boolean isConnected() {
> >        return false;
> >    }
> >
> >    public boolean isConnectionPending() {
> >        return false;
> >    }
> >
> >    public boolean connect(SocketAddress arg0) throws IOException {
> >        return false;
> >    }
> >
> >    public boolean finishConnect() throws IOException {
> >        return false;
> >    }
> >
> >    public int read(ByteBuffer arg0) throws IOException {
> >        return 0;
> >    }
> >
> >    public long read(ByteBuffer[] arg0, int arg1, int arg2) throws
> > IOException {
> >        return 0;
> >    }
> >
> >    public int write(ByteBuffer arg0) throws IOException {
> >        return 0;
> >    }
> >
> >    public long write(ByteBuffer[] arg0, int arg1, int arg2) throws
> > IOException {
> >        return 0;
> >    }
> >
> >    protected void implCloseSelectableChannel() throws IOException {
> >
> >    }
> >
> >    protected void implConfigureBlocking(boolean arg0) throws
> > IOException {
> >
> >    }
> > }
> >
> >
> >
> > On 7/27/06, Jimmy, Jing Lv <[EMAIL PROTECTED]> wrote:
> >>
> >> Hi:
> >>     I find that RI behaves strange in
> >> java.nio.channels.SelectableChannel.register. in NIO, channels and
> >> selector must be created by Provider. The doc reads: (Invoking
> >> register() should throw) "IllegalSelectorException - If this channel
> was
> >> not created by the same provider as the given selector". To check if
> the
> >> two providers are the same, Harmony use
> >> "if(selector.provider()==selector.provider)... ", however it seems
not
> >> correct.
> >>     If we mock a channel extends SelectableChannel, put the same
> >> provider of selector as its provider, and register this channel to
> >> selector, RI fails with a IllegalSelectorException though two
providers
> >> are the same. I have no idea if how RI do without checking providers
> are
> >> the same?
> >>     Another thing is that if a selector has no channels register on
it,
> >> invoke an operation of select() surely has nothing to do. In this
way,
> >> Harmony returns immediately even invoking a block select(), however
RI
> >> wait forever there, for nothing. I think Harmony's behavior is
logical,
> >> but not compatible with RI. It seems a bug of RI, I suggest keep it
as
> >> it is.
> >>
> >> --
> >>
> >> Best Regards!
> >>
> >> Jimmy, Jing Lv
> >> China Software Development Lab, IBM
> >>
> >> ---------------------------------------------------------------------
> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail:
[EMAIL PROTECTED]
> >>
> >>
> >
> >
>
>
> --
> Paulex Yang
> China Software Development Lab
> IBM
>
>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Andrew Zhang
China Software Development Lab, IBM






--

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to