Author: markt Date: Wed Sep 26 20:31:11 2012 New Revision: 1390717 URL: http://svn.apache.org/viewvc?rev=1390717&view=rev Log: No need to create runnable and wake up the selector if it isn't going to do anything.
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java?rev=1390717&r1=1390716&r2=1390717&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java Wed Sep 26 20:31:11 2012 @@ -244,14 +244,15 @@ public class NioBlockingSelector { } public void add(final KeyAttachment key, final int ops, final KeyReference ref) { + if ( key == null ) return; + NioChannel nch = key.getChannel(); + if ( nch == null ) return; + final SocketChannel ch = nch.getIOChannel(); + if ( ch == null ) return; + Runnable r = new Runnable() { @Override public void run() { - if ( key == null ) return; - NioChannel nch = key.getChannel(); - if ( nch == null ) return; - SocketChannel ch = nch.getIOChannel(); - if ( ch == null ) return; SelectionKey sk = ch.keyFor(selector); try { if (sk == null) { @@ -274,14 +275,15 @@ public class NioBlockingSelector { } public void remove(final KeyAttachment key, final int ops) { + if ( key == null ) return; + NioChannel nch = key.getChannel(); + if ( nch == null ) return; + final SocketChannel ch = nch.getIOChannel(); + if ( ch == null ) return; + Runnable r = new Runnable() { @Override public void run() { - if ( key == null ) return; - NioChannel nch = key.getChannel(); - if ( nch == null ) return; - SocketChannel ch = nch.getIOChannel(); - if ( ch == null ) return; SelectionKey sk = ch.keyFor(selector); try { if (sk == null) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org