You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/08/21 16:45:43 UTC
[tomcat] branch 9.0.x updated (213b5db -> ff135f4)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.
from 213b5db Enable session cache so session ID is available with APR
new f2a244c Improve naming
new f17eb52 Add debug log message for stream recycling
new 4787081 Improve validation of expected response
new e1c4e17 Avoid possible NPE when stream is closed
new cdeb8ee Recycle the stream when it is fully closed rather than half closed
new ff135f4 Alter approach in an attempt to reduce CI failures
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/coyote/http2/LocalStrings.properties | 1 +
java/org/apache/coyote/http2/Stream.java | 14 +++-
java/org/apache/coyote/http2/StreamProcessor.java | 6 +-
.../catalina/nonblocking/TestNonBlockingAPI.java | 24 +++++--
...AbortedUpload.java => TestCancelledUpload.java} | 77 ++++++++++++++++------
5 files changed, 93 insertions(+), 29 deletions(-)
rename test/org/apache/coyote/http2/{TestAbortedUpload.java => TestCancelledUpload.java} (58%)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 02/06: Add debug log message for stream recycling
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit f17eb521063849098d30d1466e3bace097a9685d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Aug 21 14:48:39 2020 +0100
Add debug log message for stream recycling
---
java/org/apache/coyote/http2/LocalStrings.properties | 1 +
java/org/apache/coyote/http2/Stream.java | 3 +++
2 files changed, 4 insertions(+)
diff --git a/java/org/apache/coyote/http2/LocalStrings.properties b/java/org/apache/coyote/http2/LocalStrings.properties
index 4ba59c1..e80e6d3 100644
--- a/java/org/apache/coyote/http2/LocalStrings.properties
+++ b/java/org/apache/coyote/http2/LocalStrings.properties
@@ -96,6 +96,7 @@ stream.inputBuffer.reset=Stream reset
stream.inputBuffer.signal=Data added to inBuffer when read thread is waiting. Signalling that thread to continue
stream.notWritable=Connection [{0}], Stream [{1}], This stream is not writable
stream.outputBuffer.flush.debug=Connection [{0}], Stream [{1}], flushing output with buffer at position [{2}], writeInProgress [{3}] and closed [{4}]
+stream.recycle=Connection [{0}], Stream [{1}] has been recycled
stream.reprioritisation.debug=Connection [{0}], Stream [{1}], Exclusive [{2}], Parent [{3}], Weight [{4}]
stream.reset.fail=Connection [{0}], Stream [{1}], Failed to reset stream
stream.reset.receive=Connection [{0}], Stream [{1}], Reset received due to [{2}]
diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 208ea1b..70b5e47 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -752,6 +752,9 @@ class Stream extends AbstractStream implements HeaderEmitter {
* Stream instances are retained for a period after the Stream closes.
*/
final void recycle() {
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("stream.recycle", getConnectionId(), getIdentifier()));
+ }
coyoteRequest = null;
cookieHeader = null;
coyoteResponse = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 06/06: Alter approach in an attempt to reduce CI failures
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit ff135f4f94dfab61c3a22345f8d52ab798d3940d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Aug 21 16:51:35 2020 +0100
Alter approach in an attempt to reduce CI failures
---
.../catalina/nonblocking/TestNonBlockingAPI.java | 24 ++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index e982d57..4bd68c2 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -322,7 +322,10 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
- NBWriteServlet servlet = new NBWriteServlet();
+ // Some CI platforms appear to have particularly large write buffers
+ // and appear to ignore the socket.txBufSize below. Therefore, configure
+ // configure the Servlet to keep writing until an error is encountered.
+ NBWriteServlet servlet = new NBWriteServlet(true);
String servletName = NBWriteServlet.class.getName();
Tomcat.addServlet(ctx, servletName, servlet);
ctx.addServletMappingDecoded("/", servletName);
@@ -541,9 +544,20 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@WebServlet(asyncSupported = true)
public static class NBWriteServlet extends TesterServlet {
private static final long serialVersionUID = 1L;
+ private final boolean unlimited;
public transient volatile TestWriteListener wlistener;
public transient volatile TestReadListener rlistener;
+ public NBWriteServlet() {
+ this(false);
+ }
+
+
+ public NBWriteServlet(boolean unlimited) {
+ this.unlimited = unlimited;
+ }
+
+
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// step 1 - start async
@@ -577,7 +591,7 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
in.setReadListener(rlistener);
ServletOutputStream out = resp.getOutputStream();
resp.setBufferSize(200 * 1024);
- wlistener = new TestWriteListener(actx);
+ wlistener = new TestWriteListener(actx, unlimited);
out.setWriteListener(wlistener);
}
@@ -729,18 +743,20 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
private static class TestWriteListener implements WriteListener {
AsyncContext ctx;
+ private final boolean unlimited;
int written = 0;
public volatile boolean onErrorInvoked = false;
- public TestWriteListener(AsyncContext ctx) {
+ public TestWriteListener(AsyncContext ctx, boolean unlimted) {
this.ctx = ctx;
+ this.unlimited = unlimted;
}
@Override
public void onWritePossible() throws IOException {
long start = System.currentTimeMillis();
int before = written;
- while (written < WRITE_SIZE &&
+ while ((written < WRITE_SIZE || unlimited) &&
ctx.getResponse().getOutputStream().isReady()) {
ctx.getResponse().getOutputStream().write(
DATA, written, CHUNK_SIZE);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 04/06: Avoid possible NPE when stream is closed
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit e1c4e17e1e8aac422ec27d71cf57b1a2f5f58404
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Aug 21 16:34:10 2020 +0100
Avoid possible NPE when stream is closed
---
java/org/apache/coyote/http2/Stream.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 70b5e47..30fa819 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -651,9 +651,14 @@ class Stream extends AbstractStream implements HeaderEmitter {
final boolean isContentLengthInconsistent() {
- long contentLengthHeader = coyoteRequest.getContentLengthLong();
- if (contentLengthHeader > -1 && contentLengthReceived != contentLengthHeader) {
- return true;
+ Request coyoteRequest = this.coyoteRequest;
+ // May be null when processing trailer headers after stream has been
+ // closed.
+ if (coyoteRequest != null) {
+ long contentLengthHeader = coyoteRequest.getContentLengthLong();
+ if (contentLengthHeader > -1 && contentLengthReceived != contentLengthHeader) {
+ return true;
+ }
}
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 05/06: Recycle the stream when it is fully closed rather
than half closed
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit cdeb8ee099eb787063e310b94942b843710aefff
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Aug 21 16:35:36 2020 +0100
Recycle the stream when it is fully closed rather than half closed
---
java/org/apache/coyote/http2/StreamProcessor.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java b/java/org/apache/coyote/http2/StreamProcessor.java
index 2b41753..2e40f9c 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -90,8 +90,10 @@ class StreamProcessor extends AbstractProcessor {
}
stream.close(se);
} else {
- // stream.close() will call recycle so only need it here
- stream.recycle();
+ if (!stream.isActive()) {
+ // stream.close() will call recycle so only need it here
+ stream.recycle();
+ }
}
}
} catch (Exception e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 01/06: Improve naming
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit f2a244c45bf415b59e42b398af42fd14a11bc2df
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Aug 21 12:22:35 2020 +0100
Improve naming
---
.../http2/{TestAbortedUpload.java => TestCancelledUpload.java} | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/org/apache/coyote/http2/TestAbortedUpload.java b/test/org/apache/coyote/http2/TestCancelledUpload.java
similarity index 93%
rename from test/org/apache/coyote/http2/TestAbortedUpload.java
rename to test/org/apache/coyote/http2/TestCancelledUpload.java
index 69e093b..a89dc55 100644
--- a/test/org/apache/coyote/http2/TestAbortedUpload.java
+++ b/test/org/apache/coyote/http2/TestCancelledUpload.java
@@ -31,10 +31,10 @@ import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;
-public class TestAbortedUpload extends Http2TestBase {
+public class TestCancelledUpload extends Http2TestBase {
@Test
- public void testAbortedRequest() throws Exception {
+ public void testCancelledRequest() throws Exception {
http2Connect();
http2Protocol.setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
@@ -94,14 +94,14 @@ public class TestAbortedUpload extends Http2TestBase {
// Retain '/simple' url-pattern since it enables code re-use
Context ctxt = tomcat.addContext("", null);
- Tomcat.addServlet(ctxt, "abort", new AbortServlet());
- ctxt.addServletMappingDecoded("/simple", "abort");
+ Tomcat.addServlet(ctxt, "cancel", new CancelServlet());
+ ctxt.addServletMappingDecoded("/simple", "cancel");
tomcat.start();
}
- private static class AbortServlet extends SimpleServlet {
+ private static class CancelServlet extends SimpleServlet {
private static final long serialVersionUID = 1L;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 03/06: Improve validation of expected response
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 4787081381733ca731fc4b4b83ca52198ba9b600
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Aug 21 16:33:38 2020 +0100
Improve validation of expected response
---
.../apache/coyote/http2/TestCancelledUpload.java | 67 +++++++++++++++++-----
1 file changed, 52 insertions(+), 15 deletions(-)
diff --git a/test/org/apache/coyote/http2/TestCancelledUpload.java b/test/org/apache/coyote/http2/TestCancelledUpload.java
index a89dc55..f9691ca 100644
--- a/test/org/apache/coyote/http2/TestCancelledUpload.java
+++ b/test/org/apache/coyote/http2/TestCancelledUpload.java
@@ -62,29 +62,66 @@ public class TestCancelledUpload extends Http2TestBase {
// Trailers
writeFrame(trailerFrameHeader, trailerPayload);
- // The actual response depends on timing issues. Particularly how much
- // data is transferred in StreamInputBuffer inBuffer to outBuffer on the
- // first read.
- while (output.getTrace().length() == 0) {
- try {
- parser.readFrame(true);
- if ("3-RST-[3]\n".equals(output.getTrace())) {
- output.clearTrace();
- }
- } catch (IOException ioe) {
- // Might not be any further frames after the reset
- break;
- }
+ // The Server will process the request on a separate thread to the
+ // incoming frames.
+ // The request processing thread will:
+ // - read up to 128 bytes of request body
+ // (and issue a window update for bytes read)
+ // - write a 403 response with no response body
+ // The connection processing thread will:
+ // - read the request body until the flow control window is exhausted
+ // - reset the stream if further DATA frames are received
+ parser.readFrame(true);
+
+ // If reset is first frame received end test here
+ if (output.getTrace().startsWith("3-RST-[3]\\n")) {
+ return;
+ }
+
+ // Validate any WindowSize frames (always arrive in pairs)
+ while (output.getTrace().startsWith("0-WindowSize-[")) {
+ String trace = output.getTrace();
+ int size = Integer.parseInt(trace.substring(14, trace.length() - 2));
+ output.clearTrace();
+ parser.readFrame(true);
+ Assert.assertEquals("3-WindowSize-[" + size + "]\n", output.getTrace());
+ output.clearTrace();
+ parser.readFrame(true);
}
- if (output.getTrace().startsWith("0-WindowSize-[")) {
+ // Check for reset and exit if found
+ if (output.getTrace().startsWith("3-RST-[3]\n")) {
+ return;
+ }
+
+ // Not window update, not reset, must be the response
+ parser.readFrame(true);
+ Assert.assertEquals("3-HeadersStart\n" +
+ "3-Header-[:status]-[403]\n" +
+ "3-Header-[content-length]-[0]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
+ "3-HeadersEnd\n" +
+ "3-Body-0\n" +
+ "3-EndOfStream\n",
+ output.getTrace());
+ output.clearTrace();
+
+ // There must be a reset. There may be some WindowSize frames
+ parser.readFrame(true);
+
+ // Validate any WindowSize frames (always arrive in pairs)
+ while (output.getTrace().startsWith("0-WindowSize-[")) {
String trace = output.getTrace();
int size = Integer.parseInt(trace.substring(14, trace.length() - 2));
output.clearTrace();
- // Window updates always come in pairs
parser.readFrame(true);
Assert.assertEquals("3-WindowSize-[" + size + "]\n", output.getTrace());
}
+
+ // This should be the reset
+ Assert.assertEquals("3-RST-[3]\n", output.getTrace());
+
+ // If there are any more frames after this, ignore them
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org