You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by houzhanbin <ch...@gmail.com> on 2009/03/04 14:34:11 UTC
duplicate code in NioProcessor.java
hi,developers,
I find an duplicate code in NioProcessor.java, I think they do the
same thing.
(1)
protected boolean isInterestedInRead(NioSession session) {
SelectionKey key = session.getSelectionKey();
return key.isValid() && (key.interestOps() &
SelectionKey.OP_READ) != 0;
}
(2)
protected boolean isReadable(NioSession session) {
SelectionKey key = session.getSelectionKey();
return key.isValid() && key.isReadable();
}
the code comes from mina-2.0.0-M4
thanks for your reply..
Houzhanbin
Re: duplicate code in NioProcessor.java
Posted by Julien Vermillard <jv...@archean.fr>.
Le Wed, 04 Mar 2009 21:34:11 +0800,
houzhanbin <ch...@gmail.com> a écrit :
> hi,developers,
> I find an duplicate code in NioProcessor.java, I think they do the
> same thing.
>
> (1)
> protected boolean isInterestedInRead(NioSession session) {
> SelectionKey key = session.getSelectionKey();
> return key.isValid() && (key.interestOps() &
> SelectionKey.OP_READ) != 0;
> }
> (2)
> protected boolean isReadable(NioSession session) {
> SelectionKey key = session.getSelectionKey();
> return key.isValid() && key.isReadable();
> }
> the code comes from mina-2.0.0-M4
> thanks for your reply..
>
> Houzhanbin
key.isReadable() is the same as "k.readyOps() & OP_READ != 0"
it's testing ready ops and not interested in ops.
It's pretty confusing code, but not the same for me.
Julien