--- java/org/apache/tomcat/util/net/Nio2Channel.java (revision 1701673) +++ java/org/apache/tomcat/util/net/Nio2Channel.java (working copy) @@ -26,6 +26,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; + /** * Base class for a SocketChannel wrapper used by the endpoint. * This way, logic for a SSL socket channel remains the same as for @@ -33,6 +36,7 @@ */ public class Nio2Channel implements AsynchronousByteChannel { + private static final Log log = LogFactory.getLog(Nio2Channel.class); protected static ByteBuffer emptyBuf = ByteBuffer.allocate(0); protected AsynchronousSocketChannel sc = null; @@ -134,9 +138,21 @@ return super.toString()+":"+this.sc.toString(); } + private volatile Exception stack = null; @Override public Future read(ByteBuffer dst) { - return sc.read(dst); + Exception previous = stack; + try { + throw new Exception(Thread.currentThread().getName()); + } catch (Exception e) { + stack = e; + } + try { + return sc.read(dst); + } catch (java.nio.channels.ReadPendingException e) { + log.error("Read pending exception, previous read stack was: ", previous); + throw e; + } } @Override @@ -148,6 +164,11 @@ public void read(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler handler) { + try { + throw new Exception(Thread.currentThread().getName()); + } catch (Exception e) { + stack = e; + } sc.read(dst, timeout, unit, attachment, handler); }