[tomcat] branch master updated (e54267a -> 4e548a6)
This is an automated email from the ASF dual-hosted git repository. markt pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git. from e54267a Fix 64735 ServletContext.addJspFile() always fails with SecurityManager new afa2730 Latest Eclipse/EasyMock no longer requires this new d9f9933 Refactor: remove unused parameter, separate frame create and frame write new 4e548a6 Fix BufferOverflowException reported on users list The 3 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/tomcat/util/net/SocketBufferHandler.java| 11 +++ test/org/apache/catalina/realm/TestJNDIRealm.java | 1 - test/org/apache/coyote/http2/Http2TestBase.java| 18 -- test/org/apache/coyote/http2/TestHttp2Section_6_8.java | 2 +- webapps/docs/changelog.xml | 5 + 5 files changed, 25 insertions(+), 12 deletions(-) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 02/03: Refactor: remove unused parameter, separate frame create and frame write
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git commit d9f9933c2c2b8b8b4226ff23bdc31ae16838ba0f Author: Mark Thomas AuthorDate: Thu Oct 1 10:18:01 2020 +0100 Refactor: remove unused parameter, separate frame create and frame write --- test/org/apache/coyote/http2/Http2TestBase.java| 18 -- test/org/apache/coyote/http2/TestHttp2Section_6_8.java | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java index 167fd94..807c4a5 100644 --- a/test/org/apache/coyote/http2/Http2TestBase.java +++ b/test/org/apache/coyote/http2/Http2TestBase.java @@ -813,14 +813,9 @@ public abstract class Http2TestBase extends TomcatBaseTest { } -void sendGoaway(int streamId, int lastStreamId, long errorCode, byte[] debug) -throws IOException { +byte[] buildGoaway(int streamId, int lastStreamId, long errorCode) { byte[] goawayFrame = new byte[17]; -int len = 8; -if (debug != null) { -len += debug.length; -} -ByteUtil.setThreeBytes(goawayFrame, 0, len); +ByteUtil.setThreeBytes(goawayFrame, 0, 8); // Type goawayFrame[3] = FrameType.GOAWAY.getIdByte(); // No flags @@ -829,10 +824,13 @@ public abstract class Http2TestBase extends TomcatBaseTest { // Last stream ByteUtil.set31Bits(goawayFrame, 9, lastStreamId); ByteUtil.setFourBytes(goawayFrame, 13, errorCode); +return goawayFrame; +} + + +void sendGoaway(int streamId, int lastStreamId, long errorCode) throws IOException { +byte[] goawayFrame = buildGoaway(streamId, lastStreamId, errorCode); os.write(goawayFrame); -if (debug != null && debug.length > 0) { -os.write(debug); -} os.flush(); } diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java index c43a0b5..b80b1a9 100644 --- a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java +++ b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java @@ -76,7 +76,7 @@ public class TestHttp2Section_6_8 extends Http2TestBase { // HTTP2 upgrade http2Connect(); -sendGoaway(1, 1, Http2Error.NO_ERROR.getCode(), null); +sendGoaway(1, 1, Http2Error.NO_ERROR.getCode()); handleGoAwayResponse(1); } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 03/03: Fix BufferOverflowException reported on users list
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 4e548a6daae6b5e9bb3ba48d238dedacccff4745 Author: Mark Thomas AuthorDate: Thu Oct 1 10:21:17 2020 +0100 Fix BufferOverflowException reported on users list --- java/org/apache/tomcat/util/net/SocketBufferHandler.java | 11 +++ webapps/docs/changelog.xml | 5 + 2 files changed, 16 insertions(+) diff --git a/java/org/apache/tomcat/util/net/SocketBufferHandler.java b/java/org/apache/tomcat/util/net/SocketBufferHandler.java index d066240..78adf30 100644 --- a/java/org/apache/tomcat/util/net/SocketBufferHandler.java +++ b/java/org/apache/tomcat/util/net/SocketBufferHandler.java @@ -27,6 +27,17 @@ public class SocketBufferHandler { @Override public void expand(int newSize) { } +/* + * Http2AsyncParser$FrameCompletionHandler will return incomplete + * frame(s) to the buffer. If the previous frame (or concurrent write to + * a stream) triggered a connection close this call would fail with a + * BufferOverflowException as data can't be returned to a buffer of zero + * length. Override the method and make it a NO-OP to avoid triggering + * the exception. + */ +@Override +public void unReadReadBuffer(ByteBuffer returnedData) { +} }; private volatile boolean readBufferConfiguredForWrite = true; diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index bf5b40c..3d62382 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -141,6 +141,11 @@ Don't send the Keep-Alive response header if the connection has been explicitly closed. (markt) + +Avoid a BufferOverflowException if an HTTP/2 connection is +closed while the parser still has a partial HTTP/2 frame in the input +buffer. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 01/03: Latest Eclipse/EasyMock no longer requires this
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git commit afa2730a4db02c6cbc7a8542d52b560cc0b0e40b Author: Mark Thomas AuthorDate: Thu Oct 1 09:16:41 2020 +0100 Latest Eclipse/EasyMock no longer requires this --- test/org/apache/catalina/realm/TestJNDIRealm.java | 1 - 1 file changed, 1 deletion(-) diff --git a/test/org/apache/catalina/realm/TestJNDIRealm.java b/test/org/apache/catalina/realm/TestJNDIRealm.java index 6a1814c..c729be8 100644 --- a/test/org/apache/catalina/realm/TestJNDIRealm.java +++ b/test/org/apache/catalina/realm/TestJNDIRealm.java @@ -138,7 +138,6 @@ public class TestJNDIRealm { private NamingEnumeration mockSearchResults(String password) throws NamingException { -@SuppressWarnings("unchecked") NamingEnumeration searchResults = EasyMock.createNiceMock(NamingEnumeration.class); EasyMock.expect(Boolean.valueOf(searchResults.hasMore())) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 01/02: Refactor: remove unused parameter, separate frame create and frame write
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 4885c00f2c27be5fdb53bdd55a7ba3c42e9edb6d Author: Mark Thomas AuthorDate: Thu Oct 1 10:18:01 2020 +0100 Refactor: remove unused parameter, separate frame create and frame write --- test/org/apache/coyote/http2/Http2TestBase.java| 18 -- test/org/apache/coyote/http2/TestHttp2Section_6_8.java | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java index ca72aed..1d1fee5 100644 --- a/test/org/apache/coyote/http2/Http2TestBase.java +++ b/test/org/apache/coyote/http2/Http2TestBase.java @@ -810,14 +810,9 @@ public abstract class Http2TestBase extends TomcatBaseTest { } -void sendGoaway(int streamId, int lastStreamId, long errorCode, byte[] debug) -throws IOException { +byte[] buildGoaway(int streamId, int lastStreamId, long errorCode) { byte[] goawayFrame = new byte[17]; -int len = 8; -if (debug != null) { -len += debug.length; -} -ByteUtil.setThreeBytes(goawayFrame, 0, len); +ByteUtil.setThreeBytes(goawayFrame, 0, 8); // Type goawayFrame[3] = FrameType.GOAWAY.getIdByte(); // No flags @@ -826,10 +821,13 @@ public abstract class Http2TestBase extends TomcatBaseTest { // Last stream ByteUtil.set31Bits(goawayFrame, 9, lastStreamId); ByteUtil.setFourBytes(goawayFrame, 13, errorCode); +return goawayFrame; +} + + +void sendGoaway(int streamId, int lastStreamId, long errorCode) throws IOException { +byte[] goawayFrame = buildGoaway(streamId, lastStreamId, errorCode); os.write(goawayFrame); -if (debug != null && debug.length > 0) { -os.write(debug); -} os.flush(); } diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java index c43a0b5..b80b1a9 100644 --- a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java +++ b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java @@ -76,7 +76,7 @@ public class TestHttp2Section_6_8 extends Http2TestBase { // HTTP2 upgrade http2Connect(); -sendGoaway(1, 1, Http2Error.NO_ERROR.getCode(), null); +sendGoaway(1, 1, Http2Error.NO_ERROR.getCode()); handleGoAwayResponse(1); } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 02/02: Fix BufferOverflowException reported on users list
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 e2f9266306efc79c4171e1a49cb20d41b8f0f036 Author: Mark Thomas AuthorDate: Thu Oct 1 10:21:17 2020 +0100 Fix BufferOverflowException reported on users list --- java/org/apache/tomcat/util/net/SocketBufferHandler.java | 11 +++ webapps/docs/changelog.xml | 5 + 2 files changed, 16 insertions(+) diff --git a/java/org/apache/tomcat/util/net/SocketBufferHandler.java b/java/org/apache/tomcat/util/net/SocketBufferHandler.java index d066240..78adf30 100644 --- a/java/org/apache/tomcat/util/net/SocketBufferHandler.java +++ b/java/org/apache/tomcat/util/net/SocketBufferHandler.java @@ -27,6 +27,17 @@ public class SocketBufferHandler { @Override public void expand(int newSize) { } +/* + * Http2AsyncParser$FrameCompletionHandler will return incomplete + * frame(s) to the buffer. If the previous frame (or concurrent write to + * a stream) triggered a connection close this call would fail with a + * BufferOverflowException as data can't be returned to a buffer of zero + * length. Override the method and make it a NO-OP to avoid triggering + * the exception. + */ +@Override +public void unReadReadBuffer(ByteBuffer returnedData) { +} }; private volatile boolean readBufferConfiguredForWrite = true; diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 08a8aad..65c8e01 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -140,6 +140,11 @@ Don't send the Keep-Alive response header if the connection has been explicitly closed. (markt) + +Avoid a BufferOverflowException if an HTTP/2 connection is +closed while the parser still has a partial HTTP/2 frame in the input +buffer. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 9.0.x updated (e44fd93 -> e2f9266)
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 e44fd93 Fix 64735 ServletContext.addJspFile() always fails with SecurityManager new 4885c00 Refactor: remove unused parameter, separate frame create and frame write new e2f9266 Fix BufferOverflowException reported on users list The 2 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/tomcat/util/net/SocketBufferHandler.java| 11 +++ test/org/apache/coyote/http2/Http2TestBase.java| 18 -- test/org/apache/coyote/http2/TestHttp2Section_6_8.java | 2 +- webapps/docs/changelog.xml | 5 + 4 files changed, 25 insertions(+), 11 deletions(-) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 9.0.x updated: Add bug reference
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 The following commit(s) were added to refs/heads/9.0.x by this push: new e6161e8 Add bug reference e6161e8 is described below commit e6161e8faf8746b48984c075e65438e4685e9bf6 Author: Mark Thomas AuthorDate: Thu Oct 1 11:18:54 2020 +0100 Add bug reference --- webapps/docs/changelog.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 65c8e01..decf6f3 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -141,9 +141,9 @@ explicitly closed. (markt) -Avoid a BufferOverflowException if an HTTP/2 connection is -closed while the parser still has a partial HTTP/2 frame in the input -buffer. (markt) +64710: Avoid a BufferOverflowException if an +HTTP/2 connection is closed while the parser still has a partial HTTP/2 +frame in the input buffer. (markt) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch master updated: Add bug reference
This is an automated email from the ASF dual-hosted git repository. markt 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 dc64607 Add bug reference dc64607 is described below commit dc64607cdf98cbd6702b1ffd7fe9eee9157d578b Author: Mark Thomas AuthorDate: Thu Oct 1 11:18:54 2020 +0100 Add bug reference --- webapps/docs/changelog.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 3d62382..09bd6c5 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -142,9 +142,9 @@ explicitly closed. (markt) -Avoid a BufferOverflowException if an HTTP/2 connection is -closed while the parser still has a partial HTTP/2 frame in the input -buffer. (markt) +64710: Avoid a BufferOverflowException if an +HTTP/2 connection is closed while the parser still has a partial HTTP/2 +frame in the input buffer. (markt) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Refactor: remove unused parameter, separate frame create and frame write
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 69bbf30 Refactor: remove unused parameter, separate frame create and frame write 69bbf30 is described below commit 69bbf3072ac8646ea4a81c1eeebe10e6675cc386 Author: Mark Thomas AuthorDate: Thu Oct 1 10:18:01 2020 +0100 Refactor: remove unused parameter, separate frame create and frame write --- test/org/apache/coyote/http2/Http2TestBase.java| 18 -- test/org/apache/coyote/http2/TestHttp2Section_6_8.java | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java index ce61d4b..9b79f4b 100644 --- a/test/org/apache/coyote/http2/Http2TestBase.java +++ b/test/org/apache/coyote/http2/Http2TestBase.java @@ -803,14 +803,9 @@ public abstract class Http2TestBase extends TomcatBaseTest { } -void sendGoaway(int streamId, int lastStreamId, long errorCode, byte[] debug) -throws IOException { +byte[] buildGoaway(int streamId, int lastStreamId, long errorCode) { byte[] goawayFrame = new byte[17]; -int len = 8; -if (debug != null) { -len += debug.length; -} -ByteUtil.setThreeBytes(goawayFrame, 0, len); +ByteUtil.setThreeBytes(goawayFrame, 0, 8); // Type goawayFrame[3] = FrameType.GOAWAY.getIdByte(); // No flags @@ -819,10 +814,13 @@ public abstract class Http2TestBase extends TomcatBaseTest { // Last stream ByteUtil.set31Bits(goawayFrame, 9, lastStreamId); ByteUtil.setFourBytes(goawayFrame, 13, errorCode); +return goawayFrame; +} + + +void sendGoaway(int streamId, int lastStreamId, long errorCode) throws IOException { +byte[] goawayFrame = buildGoaway(streamId, lastStreamId, errorCode); os.write(goawayFrame); -if (debug != null && debug.length > 0) { -os.write(debug); -} os.flush(); } diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java index c43a0b5..b80b1a9 100644 --- a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java +++ b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java @@ -76,7 +76,7 @@ public class TestHttp2Section_6_8 extends Http2TestBase { // HTTP2 upgrade http2Connect(); -sendGoaway(1, 1, Http2Error.NO_ERROR.getCode(), null); +sendGoaway(1, 1, Http2Error.NO_ERROR.getCode()); handleGoAwayResponse(1); } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[Bug 64710] NullPointerException in Http2UpgradeHandler.endRequestBodyFrame and BufferOverflowException in SocketBufferHandler
https://bz.apache.org/bugzilla/show_bug.cgi?id=64710 Mark Thomas changed: What|Removed |Added Status|NEEDINFO|RESOLVED Resolution|--- |FIXED --- Comment #19 from Mark Thomas --- BufferOverflowException fixed in: Fixed in: - master for 10.0.0-M9 onwards - 9.0.x for 9.0.39 onwards 8.5.x is not affected. -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch master updated: Wrap 'error' and 'applicationIOE' with AtomicReference
This is an automated email from the ASF dual-hosted git repository. mgrigorov 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 14e5b8c Wrap 'error' and 'applicationIOE' with AtomicReference 14e5b8c is described below commit 14e5b8c2b1d0a88e6220a08feefba559bec2335e Author: Martin Tzvetanov Grigorov AuthorDate: Thu Oct 1 13:29:42 2020 +0300 Wrap 'error' and 'applicationIOE' with AtomicReference Under high load it is possible that one thread makes the check for non-null and before the copy another thread to null-fy the member field. SEVERE: Servlet.service() for servlet [plaintext] in context with path [] threw exception java.lang.NullPointerException: Cannot throw exception because "ioe" is null at org.apache.coyote.http2.Http2UpgradeHandler.handleAppInitiatedIOException(Http2UpgradeHandler.java:797) at org.apache.coyote.http2.Http2AsyncUpgradeHandler.handleAsyncException(Http2AsyncUpgradeHandler.java:276) at org.apache.coyote.http2.Http2AsyncUpgradeHandler.writeWindowUpdate(Http2AsyncUpgradeHandler.java:252) at org.apache.coyote.http2.Stream$StreamInputBuffer.doRead(Stream.java:1088) at org.apache.coyote.Request.doRead(Request.java:555) at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:336) at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:632) at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:362) at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:132) at org.apache.catalina.connector.Request.readPostBody(Request.java:3308) at org.apache.catalina.connector.Request.parseParameters(Request.java:3241) at org.apache.catalina.connector.Request.getParameter(Request.java:1124) at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381) at info.mgsolutions.tomcat.PlainTextServlet.doPost(PlainTextServlet.java:41) at javax.servlet.http.HttpServlet.service(HttpServlet.java:652) at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ... --- .../coyote/http2/Http2AsyncUpgradeHandler.java | 36 -- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java index 9c274ac..defbb1c 100644 --- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java @@ -25,6 +25,7 @@ import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; import jakarta.servlet.http.WebConnection; @@ -43,8 +44,8 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { // Because of the compression used, headers need to be written to the // network in the same order they are generated. private final Object headerWriteLock = new Object(); -private Throwable error = null; -private IOException applicationIOE = null; +private final AtomicReference error = new AtomicReference<>(); +private final AtomicReference applicationIOE = new AtomicReference<>(); public Http2AsyncUpgradeHandler(Http2Protocol protocol, Adapter adapter, Request coyoteRequest) { @@ -57,7 +58,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { } @Override public void failed(Throwable t, Void attachment) { -error = t; +error.set(t); } }; private final CompletionHandler applicationErrorCompletion = new CompletionHandler() { @@ -67,9 +68,9 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { @Override public void failed(Throwable t, Void attachment) { if (t instanceof IOException) { -applicationIOE = (IOException) t; +applicationIOE.set((IOException) t); } -error = t; +error.set(t); } }; @@ -109,12 +110,13 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { TimeUnit.MILLISECONDS, null, SocketWrapperBase.COMPLETE_WRITE, errorCompletion, ByteBuffer.wrap(localSettings.getSettingsFrameForPending()), ByteBuffer.wrap(createWindowUpdateForSettings())); -if (error != null) { +Throwable err = error.get(); +if (err != null) { String msg = sm.getString("upgradeHandler.sendPrefaceFail", connectionId); if (log.isDeb
[tomcat] branch 9.0.x updated: Wrap 'error' and 'applicationIOE' with AtomicReference
This is an automated email from the ASF dual-hosted git repository. mgrigorov pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new a84cdbf Wrap 'error' and 'applicationIOE' with AtomicReference a84cdbf is described below commit a84cdbfcdabefef4ed0030f430eecf7435a8ef58 Author: Martin Tzvetanov Grigorov AuthorDate: Thu Oct 1 13:29:42 2020 +0300 Wrap 'error' and 'applicationIOE' with AtomicReference Under high load it is possible that one thread makes the check for non-null and before the copy another thread to null-fy the member field. SEVERE: Servlet.service() for servlet [plaintext] in context with path [] threw exception java.lang.NullPointerException: Cannot throw exception because "ioe" is null at org.apache.coyote.http2.Http2UpgradeHandler.handleAppInitiatedIOException(Http2UpgradeHandler.java:797) at org.apache.coyote.http2.Http2AsyncUpgradeHandler.handleAsyncException(Http2AsyncUpgradeHandler.java:276) at org.apache.coyote.http2.Http2AsyncUpgradeHandler.writeWindowUpdate(Http2AsyncUpgradeHandler.java:252) at org.apache.coyote.http2.Stream$StreamInputBuffer.doRead(Stream.java:1088) at org.apache.coyote.Request.doRead(Request.java:555) at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:336) at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:632) at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:362) at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:132) at org.apache.catalina.connector.Request.readPostBody(Request.java:3308) at org.apache.catalina.connector.Request.parseParameters(Request.java:3241) at org.apache.catalina.connector.Request.getParameter(Request.java:1124) at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381) at info.mgsolutions.tomcat.PlainTextServlet.doPost(PlainTextServlet.java:41) at javax.servlet.http.HttpServlet.service(HttpServlet.java:652) at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ... (cherry picked from commit 71b70117042bf646183e9e0395625dc1dcbf1333) --- .../coyote/http2/Http2AsyncUpgradeHandler.java | 36 -- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java index eb116a7..2068044 100644 --- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java @@ -25,6 +25,7 @@ import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; import javax.servlet.http.WebConnection; @@ -43,8 +44,8 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { // Because of the compression used, headers need to be written to the // network in the same order they are generated. private final Object headerWriteLock = new Object(); -private Throwable error = null; -private IOException applicationIOE = null; +private final AtomicReference error = new AtomicReference<>(); +private final AtomicReference applicationIOE = new AtomicReference<>(); public Http2AsyncUpgradeHandler(Http2Protocol protocol, Adapter adapter, Request coyoteRequest) { @@ -57,7 +58,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { } @Override public void failed(Throwable t, Void attachment) { -error = t; +error.set(t); } }; private final CompletionHandler applicationErrorCompletion = new CompletionHandler() { @@ -67,9 +68,9 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { @Override public void failed(Throwable t, Void attachment) { if (t instanceof IOException) { -applicationIOE = (IOException) t; +applicationIOE.set((IOException) t); } -error = t; +error.set(t); } }; @@ -109,12 +110,13 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { TimeUnit.MILLISECONDS, null, SocketWrapperBase.COMPLETE_WRITE, errorCompletion, ByteBuffer.wrap(localSettings.getSettingsFrameForPending()), ByteBuffer.wrap(createWindowUpdateForSettings())); -if (error != null) { +Throwable err = error.get(); +if (err != null) { String msg = sm.getString("u
[tomcat] branch 9.0.x updated: Additional debug logging for gump
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 The following commit(s) were added to refs/heads/9.0.x by this push: new c8ec2d4 Additional debug logging for gump c8ec2d4 is described below commit c8ec2d4cde3a31b0e9df9a30e7915d77ba725545 Author: Mark Thomas AuthorDate: Thu Oct 1 11:36:36 2020 +0100 Additional debug logging for gump --- .../apache/coyote/http2/TestHttp2Section_6_1.java | 61 -- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_1.java b/test/org/apache/coyote/http2/TestHttp2Section_6_1.java index 8e3d948..32d2de9 100644 --- a/test/org/apache/coyote/http2/TestHttp2Section_6_1.java +++ b/test/org/apache/coyote/http2/TestHttp2Section_6_1.java @@ -157,37 +157,44 @@ public class TestHttp2Section_6_1 extends Http2TestBase { @Test public void testDataFrameWithZeroLengthPadding() throws Exception { -http2Connect(); + LogManager.getLogManager().getLogger("org.apache.coyote").setLevel(Level.ALL); + LogManager.getLogManager().getLogger("org.apache.tomcat.util.net").setLevel(Level.ALL); +try { +http2Connect(); -byte[] padding = new byte[0]; +byte[] padding = new byte[0]; -sendSimplePostRequest(3, padding); -readSimplePostResponse(true); +sendSimplePostRequest(3, padding); +readSimplePostResponse(true); -// The window updates for padding could occur anywhere since they -// happen on a different thread to the response. -// The connection window update is always present if there is -// padding. -String trace = output.getTrace(); -String paddingWindowUpdate = "0-WindowSize-[1]\n"; -Assert.assertTrue(trace, trace.contains(paddingWindowUpdate)); -trace = trace.replace(paddingWindowUpdate, ""); - -// The stream window update may or may not be present depending on -// timing. Remove it if present. -paddingWindowUpdate = "3-WindowSize-[1]\n"; -if (trace.contains(paddingWindowUpdate)) { +// The window updates for padding could occur anywhere since they +// happen on a different thread to the response. +// The connection window update is always present if there is +// padding. +String trace = output.getTrace(); +String paddingWindowUpdate = "0-WindowSize-[1]\n"; +Assert.assertTrue(trace, trace.contains(paddingWindowUpdate)); trace = trace.replace(paddingWindowUpdate, ""); -} -Assert.assertEquals("0-WindowSize-[127]\n" + -"3-WindowSize-[127]\n" + -"3-HeadersStart\n" + -"3-Header-[:status]-[200]\n" + -"3-Header-[content-length]-[127]\n" + -"3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + -"3-HeadersEnd\n" + -"3-Body-127\n" + -"3-EndOfStream\n", trace); +// The stream window update may or may not be present depending on +// timing. Remove it if present. +paddingWindowUpdate = "3-WindowSize-[1]\n"; +if (trace.contains(paddingWindowUpdate)) { +trace = trace.replace(paddingWindowUpdate, ""); +} + +Assert.assertEquals("0-WindowSize-[127]\n" + +"3-WindowSize-[127]\n" + +"3-HeadersStart\n" + +"3-Header-[:status]-[200]\n" + +"3-Header-[content-length]-[127]\n" + +"3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + +"3-HeadersEnd\n" + +"3-Body-127\n" + +"3-EndOfStream\n", trace); +} finally { + LogManager.getLogManager().getLogger("org.apache.coyote").setLevel(Level.INFO); + LogManager.getLogManager().getLogger("org.apache.tomcat.util.net").setLevel(Level.INFO); +} } } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Additional debug logging for gump
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 11e5a71 Additional debug logging for gump 11e5a71 is described below commit 11e5a713f71540d0ca6ad060d79b452cb81660d0 Author: Mark Thomas AuthorDate: Thu Oct 1 11:36:36 2020 +0100 Additional debug logging for gump --- .../apache/coyote/http2/TestHttp2Section_6_1.java | 61 -- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_1.java b/test/org/apache/coyote/http2/TestHttp2Section_6_1.java index 8e3d948..32d2de9 100644 --- a/test/org/apache/coyote/http2/TestHttp2Section_6_1.java +++ b/test/org/apache/coyote/http2/TestHttp2Section_6_1.java @@ -157,37 +157,44 @@ public class TestHttp2Section_6_1 extends Http2TestBase { @Test public void testDataFrameWithZeroLengthPadding() throws Exception { -http2Connect(); + LogManager.getLogManager().getLogger("org.apache.coyote").setLevel(Level.ALL); + LogManager.getLogManager().getLogger("org.apache.tomcat.util.net").setLevel(Level.ALL); +try { +http2Connect(); -byte[] padding = new byte[0]; +byte[] padding = new byte[0]; -sendSimplePostRequest(3, padding); -readSimplePostResponse(true); +sendSimplePostRequest(3, padding); +readSimplePostResponse(true); -// The window updates for padding could occur anywhere since they -// happen on a different thread to the response. -// The connection window update is always present if there is -// padding. -String trace = output.getTrace(); -String paddingWindowUpdate = "0-WindowSize-[1]\n"; -Assert.assertTrue(trace, trace.contains(paddingWindowUpdate)); -trace = trace.replace(paddingWindowUpdate, ""); - -// The stream window update may or may not be present depending on -// timing. Remove it if present. -paddingWindowUpdate = "3-WindowSize-[1]\n"; -if (trace.contains(paddingWindowUpdate)) { +// The window updates for padding could occur anywhere since they +// happen on a different thread to the response. +// The connection window update is always present if there is +// padding. +String trace = output.getTrace(); +String paddingWindowUpdate = "0-WindowSize-[1]\n"; +Assert.assertTrue(trace, trace.contains(paddingWindowUpdate)); trace = trace.replace(paddingWindowUpdate, ""); -} -Assert.assertEquals("0-WindowSize-[127]\n" + -"3-WindowSize-[127]\n" + -"3-HeadersStart\n" + -"3-Header-[:status]-[200]\n" + -"3-Header-[content-length]-[127]\n" + -"3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + -"3-HeadersEnd\n" + -"3-Body-127\n" + -"3-EndOfStream\n", trace); +// The stream window update may or may not be present depending on +// timing. Remove it if present. +paddingWindowUpdate = "3-WindowSize-[1]\n"; +if (trace.contains(paddingWindowUpdate)) { +trace = trace.replace(paddingWindowUpdate, ""); +} + +Assert.assertEquals("0-WindowSize-[127]\n" + +"3-WindowSize-[127]\n" + +"3-HeadersStart\n" + +"3-Header-[:status]-[200]\n" + +"3-Header-[content-length]-[127]\n" + +"3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + +"3-HeadersEnd\n" + +"3-Body-127\n" + +"3-EndOfStream\n", trace); +} finally { + LogManager.getLogManager().getLogger("org.apache.coyote").setLevel(Level.INFO); + LogManager.getLogManager().getLogger("org.apache.tomcat.util.net").setLevel(Level.INFO); +} } } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch master updated: Fix test failure - don't try and connect to an i/f that is down
This is an automated email from the ASF dual-hosted git repository. markt 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 127e85e Fix test failure - don't try and connect to an i/f that is down 127e85e is described below commit 127e85e7b3989701ced95ccc1f4793112b92e38f Author: Mark Thomas AuthorDate: Thu Oct 1 14:15:49 2020 +0100 Fix test failure - don't try and connect to an i/f that is down --- .../jni/TestSocketServerAnyLocalAddress.java | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java b/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java index 0023db2..c983608 100644 --- a/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java +++ b/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java @@ -182,21 +182,23 @@ public class TestSocketServerAnyLocalAddress extends AbstractJniTest { Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = networkInterfaces.nextElement(); -Enumeration inetAddresses = networkInterface.getInetAddresses(); -while (inetAddresses.hasMoreElements()) { -InetAddress inetAddress = inetAddresses.nextElement(); -if (localAddress.getAddress().getClass().isAssignableFrom(inetAddress.getClass())) { -if (inetAddress.isLoopbackAddress()) { -if (loopbackConnectAddress == null) { -loopbackConnectAddress = inetAddress; +if (networkInterface.isUp()) { +Enumeration inetAddresses = networkInterface.getInetAddresses(); +while (inetAddresses.hasMoreElements()) { +InetAddress inetAddress = inetAddresses.nextElement(); +if (localAddress.getAddress().getClass().isAssignableFrom(inetAddress.getClass())) { +if (inetAddress.isLoopbackAddress()) { +if (loopbackConnectAddress == null) { +loopbackConnectAddress = inetAddress; +} +} else if (inetAddress.isLinkLocalAddress()) { +if (linkLocalConnectAddress == null) { +linkLocalConnectAddress = inetAddress; +} +} else { +// Use a non-link local, non-loop back address by default +return new InetSocketAddress(inetAddress, localAddress.getPort()); } -} else if (inetAddress.isLinkLocalAddress()) { -if (linkLocalConnectAddress == null) { -linkLocalConnectAddress = inetAddress; -} -} else { -// Use a non-link local, non-loop back address by default -return new InetSocketAddress(inetAddress, localAddress.getPort()); } } } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 9.0.x updated: Fix test failure - don't try and connect to an i/f that is down
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 The following commit(s) were added to refs/heads/9.0.x by this push: new 1dc46d4 Fix test failure - don't try and connect to an i/f that is down 1dc46d4 is described below commit 1dc46d49bfe19732ef9544e20c6354f6a2a6bd66 Author: Mark Thomas AuthorDate: Thu Oct 1 14:15:49 2020 +0100 Fix test failure - don't try and connect to an i/f that is down --- .../jni/TestSocketServerAnyLocalAddress.java | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java b/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java index 0023db2..c983608 100644 --- a/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java +++ b/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java @@ -182,21 +182,23 @@ public class TestSocketServerAnyLocalAddress extends AbstractJniTest { Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = networkInterfaces.nextElement(); -Enumeration inetAddresses = networkInterface.getInetAddresses(); -while (inetAddresses.hasMoreElements()) { -InetAddress inetAddress = inetAddresses.nextElement(); -if (localAddress.getAddress().getClass().isAssignableFrom(inetAddress.getClass())) { -if (inetAddress.isLoopbackAddress()) { -if (loopbackConnectAddress == null) { -loopbackConnectAddress = inetAddress; +if (networkInterface.isUp()) { +Enumeration inetAddresses = networkInterface.getInetAddresses(); +while (inetAddresses.hasMoreElements()) { +InetAddress inetAddress = inetAddresses.nextElement(); +if (localAddress.getAddress().getClass().isAssignableFrom(inetAddress.getClass())) { +if (inetAddress.isLoopbackAddress()) { +if (loopbackConnectAddress == null) { +loopbackConnectAddress = inetAddress; +} +} else if (inetAddress.isLinkLocalAddress()) { +if (linkLocalConnectAddress == null) { +linkLocalConnectAddress = inetAddress; +} +} else { +// Use a non-link local, non-loop back address by default +return new InetSocketAddress(inetAddress, localAddress.getPort()); } -} else if (inetAddress.isLinkLocalAddress()) { -if (linkLocalConnectAddress == null) { -linkLocalConnectAddress = inetAddress; -} -} else { -// Use a non-link local, non-loop back address by default -return new InetSocketAddress(inetAddress, localAddress.getPort()); } } } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
svn/git for website
Hi all, The topic came up at the BoF session at the end of the Tomcat track of migrating the website from svn to git. There were strong opinions both for migrating and for sticking with svn. As a middle ground I'd like to propose we ask Infra to create a git mirror of the svn repo. For those who favour git: The git mirror would be read-only but it would be possible to: - clone the git mirror - make changes in git - use git-svn to commit those changes back to svn - then the mirror automatically replicates them back to git For those who favour svn there would be no change. If there is agreement on this approach, I volunteer to contact infra to get it set up. Thoughts? Mark - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org