This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new d3bd3f7 Add missing check in registerReadInterest new 9e5d3f1 Merge branch 'master' of g...@github.com:apache/tomcat.git d3bd3f7 is described below commit d3bd3f71ea04c26f638a9a43586fb7d63bbf5ae8 Author: remm <r...@apache.org> AuthorDate: Thu Feb 28 23:12:52 2019 +0100 Add missing check in registerReadInterest Follow up for 63182, and test with CI. Simplify test case a bit. --- java/org/apache/tomcat/util/net/Nio2Endpoint.java | 20 ++++++++++++++------ .../catalina/nonblocking/TestNonBlockingAPI.java | 6 +----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java index dbabe56..982dd44 100644 --- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java +++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java @@ -782,9 +782,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS throw new IOException(sm.getString("socket.closed")); } - if (readNotify) { - readNotify = false; - } else { + if (!readNotify) { if (block) { try { readPending.acquire(); @@ -803,6 +801,10 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS int nRead = populateReadBuffer(b, off, len); if (nRead > 0) { + if (readNotify) { + // The code that was notified is now reading its data + readNotify = false; + } // This may be sufficient to complete the request and we // don't want to trigger another read since if there is no // more data to read and this request takes a while to @@ -839,9 +841,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS throw new IOException(sm.getString("socket.closed")); } - if (readNotify) { - readNotify = false; - } else { + if (!readNotify) { if (block) { try { readPending.acquire(); @@ -860,6 +860,10 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS int nRead = populateReadBuffer(to); if (nRead > 0) { + if (readNotify) { + // The code that was notified is now reading its data + readNotify = false; + } // This may be sufficient to complete the request and we // don't want to trigger another read since if there is no // more data to read and this request takes a while to @@ -1490,6 +1494,10 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS @Override public void registerReadInterest() { synchronized (readCompletionHandler) { + // A notification is already being sent + if (readNotify) { + return; + } if (readPending.availablePermits() == 0) { readInterest = true; } else { diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java index 8725623..042b6f3 100644 --- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java +++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java @@ -678,16 +678,12 @@ public class TestNonBlockingAPI extends TomcatBaseTest { public void run() { try { ServletInputStream in = ctx.getRequest().getInputStream(); - String s = ""; byte[] b = new byte[1024]; int read = in.read(b); if (read == -1) { return; } - s += new String(b, 0, read); - synchronized (body) { - body.append(s); - } + body.append(new String(b, 0, read)); boolean isReady = ignoreIsReady || in.isReady(); if (isReady) { isReadyCount.incrementAndGet(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org