Author: markt Date: Wed Aug 14 15:02:59 2013 New Revision: 1513919 URL: http://svn.apache.org/r1513919 Log: Fix non-blocking test failures on OSX.
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1513919&r1=1513918&r2=1513919&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original) +++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Wed Aug 14 15:02:59 2013 @@ -363,6 +363,10 @@ public class CoyoteAdapter implements Ad try { Thread.currentThread().setContextClassLoader(newCL); res.onWritePossible(); + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + res.getWriteListener().onError(t); + return false; } finally { Thread.currentThread().setContextClassLoader(oldCL); } @@ -379,6 +383,10 @@ public class CoyoteAdapter implements Ad if (request.isFinished()) { req.getReadListener().onAllDataRead(); } + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + req.getReadListener().onError(t); + return false; } finally { Thread.currentThread().setContextClassLoader(oldCL); } Modified: tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java?rev=1513919&r1=1513918&r2=1513919&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java (original) +++ tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java Wed Aug 14 15:02:59 2013 @@ -482,25 +482,20 @@ public class TestNonBlockingAPI extends } @Override - public void onDataAvailable() { - try { - ServletInputStream in = ctx.getRequest().getInputStream(); - String s = ""; - byte[] b = new byte[8192]; - int read = 0; - do { - read = in.read(b); - if (read == -1) { - break; - } - s += new String(b, 0, read); - } while (in.isReady()); - log.info(s); - body.append(s); - } catch (Exception x) { - x.printStackTrace(); - ctx.complete(); - } + public void onDataAvailable() throws IOException { + ServletInputStream in = ctx.getRequest().getInputStream(); + String s = ""; + byte[] b = new byte[8192]; + int read = 0; + do { + read = in.read(b); + if (read == -1) { + break; + } + s += new String(b, 0, read); + } while (in.isReady()); + log.info(s); + body.append(s); } @Override @@ -537,35 +532,30 @@ public class TestNonBlockingAPI extends } @Override - public void onWritePossible() { - try { - long start = System.currentTimeMillis(); - long end = System.currentTimeMillis(); - int before = written; - while (written < WRITE_SIZE && - ctx.getResponse().getOutputStream().isReady()) { - ctx.getResponse().getOutputStream().write( - DATA, written, CHUNK_SIZE); - written += CHUNK_SIZE; - } - if (written == WRITE_SIZE) { - // Clear the output buffer else data may be lost when - // calling complete - ctx.getResponse().flushBuffer(); - } - log.info("Write took:" + (end - start) + - " ms. Bytes before=" + before + " after=" + written); - // only call complete if we have emptied the buffer - if (ctx.getResponse().getOutputStream().isReady() && - written == WRITE_SIZE) { - // it is illegal to call complete - // if there is a write in progress - ctx.complete(); - } - } catch (Exception x) { - x.printStackTrace(); + public void onWritePossible() throws IOException { + long start = System.currentTimeMillis(); + long end = System.currentTimeMillis(); + int before = written; + while (written < WRITE_SIZE && + ctx.getResponse().getOutputStream().isReady()) { + ctx.getResponse().getOutputStream().write( + DATA, written, CHUNK_SIZE); + written += CHUNK_SIZE; + } + if (written == WRITE_SIZE) { + // Clear the output buffer else data may be lost when + // calling complete + ctx.getResponse().flushBuffer(); + } + log.info("Write took:" + (end - start) + + " ms. Bytes before=" + before + " after=" + written); + // only call complete if we have emptied the buffer + if (ctx.getResponse().getOutputStream().isReady() && + written == WRITE_SIZE) { + // it is illegal to call complete + // if there is a write in progress + ctx.complete(); } - } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org