Browse files

Make sure a selector isn't canceled before reading it

If a selector is canceled then isReadable will throw an exception.
To avoid this exception and do the right thing make sure that the
selector is valid before checking if it is readable.

Change-Id: If3f9542e371eaeddf2bdea05b14b6d7263803e6a
Reviewed-on: http://review.couchbase.org/6920
Tested-by: Michael Wiederhold <mike@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
  • Loading branch information...
1 parent f552ef9 commit 0e5c16c3e79d21beefda0cef6601022866943845 Mike Wiederhold committed with mikewied Jun 9, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/main/java/net/spy/memcached/MemcachedConnection.java
View
4 src/main/java/net/spy/memcached/MemcachedConnection.java
@@ -421,10 +421,10 @@ private void handleIO(SelectionKey sk) {
assert !channel.isConnected() : "connected";
}
} else {
- if(sk.isReadable()) {
+ if(sk.isValid() && sk.isReadable()) {
handleReads(sk, qa);
}
- if(sk.isWritable()) {
+ if(sk.isValid() && sk.isWritable()) {
handleWrites(sk, qa);
}
}

0 comments on commit 0e5c16c

Please sign in to comment.