You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2014/10/12 08:55:33 UTC
git commit: Added a check on the key we get back from the
getSelectionKey() : if it's not valid,
we get out of the method without trying to set a interest flag on it.
Repository: mina
Updated Branches:
refs/heads/2.0 27abeb33f -> e206c43a1
Added a check on the key we get back from the getSelectionKey() : if
it's not valid, we get out of the method without trying to set a
interest flag on it.
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/e206c43a
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/e206c43a
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/e206c43a
Branch: refs/heads/2.0
Commit: e206c43a1bde2aac5e139a35a6266c9171e636a6
Parents: 27abeb3
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Sun Oct 12 08:50:00 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Sun Oct 12 08:50:00 2014 +0200
----------------------------------------------------------------------
.../mina/transport/socket/nio/NioProcessor.java | 21 ++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/e206c43a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
index 3692ea9..6730ba1 100644
--- a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
+++ b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
@@ -155,7 +155,7 @@ public final class NioProcessor extends AbstractPollingIoProcessor<NioSession> {
Selector newSelector = null;
if (selectorProvider == null) {
- newSelector = Selector.open();
+ newSelector = Selector.open();
} else {
newSelector = selectorProvider.openSelector();
}
@@ -232,25 +232,29 @@ public final class NioProcessor extends AbstractPollingIoProcessor<NioSession> {
@Override
protected boolean isReadable(NioSession session) {
SelectionKey key = session.getSelectionKey();
- return key.isValid() && key.isReadable();
+
+ return (key != null) && key.isValid() && key.isReadable();
}
@Override
protected boolean isWritable(NioSession session) {
SelectionKey key = session.getSelectionKey();
- return key.isValid() && key.isWritable();
+
+ return (key != null) && key.isValid() && key.isWritable();
}
@Override
protected boolean isInterestedInRead(NioSession session) {
SelectionKey key = session.getSelectionKey();
- return key.isValid() && ((key.interestOps() & SelectionKey.OP_READ) != 0);
+
+ return (key != null) && key.isValid() && ((key.interestOps() & SelectionKey.OP_READ) != 0);
}
@Override
protected boolean isInterestedInWrite(NioSession session) {
SelectionKey key = session.getSelectionKey();
- return key.isValid() && ((key.interestOps() & SelectionKey.OP_WRITE) != 0);
+
+ return (key != null) && key.isValid() && ((key.interestOps() & SelectionKey.OP_WRITE) != 0);
}
/**
@@ -259,6 +263,11 @@ public final class NioProcessor extends AbstractPollingIoProcessor<NioSession> {
@Override
protected void setInterestedInRead(NioSession session, boolean isInterested) throws Exception {
SelectionKey key = session.getSelectionKey();
+
+ if ((key == null) || !key.isValid()) {
+ return;
+ }
+
int oldInterestOps = key.interestOps();
int newInterestOps = oldInterestOps;
@@ -280,7 +289,7 @@ public final class NioProcessor extends AbstractPollingIoProcessor<NioSession> {
protected void setInterestedInWrite(NioSession session, boolean isInterested) throws Exception {
SelectionKey key = session.getSelectionKey();
- if (key == null) {
+ if ((key == null) || !key.isValid()) {
return;
}