[Bug 68228] 9.0.83 no more allows setting a status code on a read exception
https://bz.apache.org/bugzilla/show_bug.cgi?id=68228 --- Comment #1 from Mark Thomas --- I suspect the fix for CVE-2023-46589 was responsible for this change. I'll take another look and see if there is a way to get Tomcat to use 408 for a read timeout. -- 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 main updated: Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/main by this push: new 5bc57a82fe Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch 5bc57a82fe is described below commit 5bc57a82feef407e7b0843c9ce3f00feec2fc701 Author: Mark Thomas AuthorDate: Thu Nov 30 12:50:58 2023 + Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch --- java/org/apache/coyote/AsyncStateMachine.java | 1 + .../TestAsyncContextImplListenerOnComplete.java| 182 + webapps/docs/changelog.xml | 5 + 3 files changed, 188 insertions(+) diff --git a/java/org/apache/coyote/AsyncStateMachine.java b/java/org/apache/coyote/AsyncStateMachine.java index be322c6426..42108086e6 100644 --- a/java/org/apache/coyote/AsyncStateMachine.java +++ b/java/org/apache/coyote/AsyncStateMachine.java @@ -292,6 +292,7 @@ class AsyncStateMachine { if (processor.getErrorState().isIoAllowed() && processor.flushBufferedWrite()) { return SocketState.LONG; } +asyncCtxt.fireOnComplete(); updateState(AsyncState.DISPATCHED); asyncCtxt.decrementInProgressAsyncCount(); return SocketState.ASYNC_END; diff --git a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java new file mode 100644 index 00..0e18405cda --- /dev/null +++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.core; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import jakarta.servlet.AsyncContext; +import jakarta.servlet.AsyncEvent; +import jakarta.servlet.AsyncListener; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.junit.Assert; +import org.junit.Test; + +import org.apache.catalina.Context; +import org.apache.catalina.Wrapper; +import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.startup.TomcatBaseTest; + +public class TestAsyncContextImplListenerOnComplete extends TomcatBaseTest { + +/* + * https://bz.apache.org/bugzilla/show_bug.cgi?id=68227 + */ +@Test +public void testAfterNetworkErrorThenDispatch() throws Exception { +// Setup Tomcat instance +Tomcat tomcat = getTomcatInstance(); + +// No file system docBase required +Context ctx = tomcat.addContext("", null); + +// Latch to track that complete has been called +CountDownLatch completeLatch = new CountDownLatch(1); + +Wrapper servletWrapper = tomcat.addServlet("", "repro-servlet", new ReproServlet(completeLatch)); +servletWrapper.addMapping("/repro"); +servletWrapper.setAsyncSupported(true); +servletWrapper.setLoadOnStartup(1); + +ctx.addServletMappingDecoded("/", "repro-servlet"); + +tomcat.start(); +Thread.sleep(2000); + +triggerBrokenPipe(getPort()); + +Assert.assertTrue(completeLatch.await(30, TimeUnit.SECONDS)); +} + + +private void triggerBrokenPipe(int port) throws IOException, InterruptedException { +try (Socket socket = new Socket()) { +socket.setReceiveBufferSize(1); +socket.connect(new InetSocketAddress("localhost", port)); + +try (var writer = new OutputStreamWriter(socket.getOutputStream())) { +writer.write(""" +GET /repro +Accept: text/event-stream + +"""); +writer.flush(); +} +Thread.sleep(1_000); +} +} + + +private static class Repro
(tomcat) branch 10.1.x updated: Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 957148db16 Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch 957148db16 is described below commit 957148db169df9d5340d0499a9d137ebacd46964 Author: Mark Thomas AuthorDate: Thu Nov 30 12:50:58 2023 + Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch --- java/org/apache/coyote/AsyncStateMachine.java | 1 + .../TestAsyncContextImplListenerOnComplete.java| 181 + webapps/docs/changelog.xml | 5 + 3 files changed, 187 insertions(+) diff --git a/java/org/apache/coyote/AsyncStateMachine.java b/java/org/apache/coyote/AsyncStateMachine.java index a651def252..b5e5193d59 100644 --- a/java/org/apache/coyote/AsyncStateMachine.java +++ b/java/org/apache/coyote/AsyncStateMachine.java @@ -289,6 +289,7 @@ class AsyncStateMachine { updateState(AsyncState.DISPATCHING); return SocketState.ASYNC_END; } else if (state == AsyncState.DISPATCHING) { +asyncCtxt.fireOnComplete(); updateState(AsyncState.DISPATCHED); asyncCtxt.decrementInProgressAsyncCount(); return SocketState.ASYNC_END; diff --git a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java new file mode 100644 index 00..e609d745e0 --- /dev/null +++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java @@ -0,0 +1,181 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.core; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import jakarta.servlet.AsyncContext; +import jakarta.servlet.AsyncEvent; +import jakarta.servlet.AsyncListener; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.junit.Assert; +import org.junit.Test; + +import org.apache.catalina.Context; +import org.apache.catalina.Wrapper; +import org.apache.catalina.startup.SimpleHttpClient; +import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.startup.TomcatBaseTest; + +public class TestAsyncContextImplListenerOnComplete extends TomcatBaseTest { + +/* + * https://bz.apache.org/bugzilla/show_bug.cgi?id=68227 + */ +@Test +public void testAfterNetworkErrorThenDispatch() throws Exception { +// Setup Tomcat instance +Tomcat tomcat = getTomcatInstance(); + +// No file system docBase required +Context ctx = tomcat.addContext("", null); + +// Latch to track that complete has been called +CountDownLatch completeLatch = new CountDownLatch(1); + +Wrapper servletWrapper = tomcat.addServlet("", "repro-servlet", new ReproServlet(completeLatch)); +servletWrapper.addMapping("/repro"); +servletWrapper.setAsyncSupported(true); +servletWrapper.setLoadOnStartup(1); + +ctx.addServletMappingDecoded("/", "repro-servlet"); + +tomcat.start(); +Thread.sleep(2000); + +triggerBrokenPipe(getPort()); + +Assert.assertTrue(completeLatch.await(30, TimeUnit.SECONDS)); +} + + +private void triggerBrokenPipe(int port) throws IOException, InterruptedException { +try (Socket socket = new Socket()) { +socket.setReceiveBufferSize(1); +socket.connect(new InetSocketAddress("localhost", port)); + +try (var writer = new OutputStreamWriter(socket.getOutputStream())) { +writer.write("GET /repro" + SimpleHttpClient.CRLF + +"Accept: text/event-stream" + SimpleHttpClient.CRLF + +SimpleHttpClient.CRLF); +writer.fl
(tomcat) branch 9.0.x updated: Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch
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 2daab189ab Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch 2daab189ab is described below commit 2daab189ab3c85aed23d5797f5abf44c59936dbc Author: Mark Thomas AuthorDate: Thu Nov 30 12:50:58 2023 + Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch --- java/org/apache/coyote/AsyncStateMachine.java | 1 + .../TestAsyncContextImplListenerOnComplete.java| 183 + webapps/docs/changelog.xml | 5 + 3 files changed, 189 insertions(+) diff --git a/java/org/apache/coyote/AsyncStateMachine.java b/java/org/apache/coyote/AsyncStateMachine.java index a651def252..b5e5193d59 100644 --- a/java/org/apache/coyote/AsyncStateMachine.java +++ b/java/org/apache/coyote/AsyncStateMachine.java @@ -289,6 +289,7 @@ class AsyncStateMachine { updateState(AsyncState.DISPATCHING); return SocketState.ASYNC_END; } else if (state == AsyncState.DISPATCHING) { +asyncCtxt.fireOnComplete(); updateState(AsyncState.DISPATCHED); asyncCtxt.decrementInProgressAsyncCount(); return SocketState.ASYNC_END; diff --git a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java new file mode 100644 index 00..3a7bd20a86 --- /dev/null +++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.core; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Writer; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.servlet.AsyncContext; +import javax.servlet.AsyncEvent; +import javax.servlet.AsyncListener; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Assert; +import org.junit.Test; + +import org.apache.catalina.Context; +import org.apache.catalina.Wrapper; +import org.apache.catalina.startup.SimpleHttpClient; +import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.startup.TomcatBaseTest; + +public class TestAsyncContextImplListenerOnComplete extends TomcatBaseTest { + +/* + * https://bz.apache.org/bugzilla/show_bug.cgi?id=68227 + */ +@Test +public void testAfterNetworkErrorThenDispatch() throws Exception { +// Setup Tomcat instance +Tomcat tomcat = getTomcatInstance(); + +// No file system docBase required +Context ctx = tomcat.addContext("", null); + +// Latch to track that complete has been called +CountDownLatch completeLatch = new CountDownLatch(1); + +Wrapper servletWrapper = tomcat.addServlet("", "repro-servlet", new ReproServlet(completeLatch)); +servletWrapper.addMapping("/repro"); +servletWrapper.setAsyncSupported(true); +servletWrapper.setLoadOnStartup(1); + +ctx.addServletMappingDecoded("/", "repro-servlet"); + +tomcat.start(); +Thread.sleep(2000); + +triggerBrokenPipe(getPort()); + +Assert.assertTrue(completeLatch.await(30, TimeUnit.SECONDS)); +} + + +private void triggerBrokenPipe(int port) throws IOException, InterruptedException { +try (Socket socket = new Socket()) { +socket.setReceiveBufferSize(1); +socket.connect(new InetSocketAddress("localhost", port)); + +try (Writer writer = new OutputStreamWriter(socket.getOutputStream())) { +writer.write("GET /repro" + SimpleHttpClient.CRLF + +"Accept: text/event-stream" + SimpleHttpClient.CRLF + +
[Bug 68228] Status code can no longer be set after a read exception in 9.0.83 or later
https://bz.apache.org/bugzilla/show_bug.cgi?id=68228 Christopher Schultz changed: What|Removed |Added Summary|9.0.83 no more allows |Status code can no longer |setting a status code on a |be set after a read |read exception |exception in 9.0.83 or ||later -- 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
[Bug 68228] Status code can no longer be set after a read exception occurs in 9.0.83 or later
https://bz.apache.org/bugzilla/show_bug.cgi?id=68228 Christopher Schultz changed: What|Removed |Added Summary|Status code can no longer |Status code can no longer |be set after a read |be set after a read |exception in 9.0.83 or |exception occurs in 9.0.83 |later |or later -- 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
svn commit: r1914238 - in /tomcat/site/trunk: docs/index.html docs/upgrading.html xdocs/stylesheets/project.xml xdocs/upgrading.xml
Author: schultz Date: Thu Nov 30 16:52:59 2023 New Revision: 1914238 URL: http://svn.apache.org/viewvc?rev=1914238&view=rev Log: Add an "Upgrading" page. Added: tomcat/site/trunk/docs/upgrading.html tomcat/site/trunk/xdocs/upgrading.xml Modified: tomcat/site/trunk/docs/index.html tomcat/site/trunk/xdocs/stylesheets/project.xml Modified: tomcat/site/trunk/docs/index.html URL: http://svn.apache.org/viewvc/tomcat/site/trunk/docs/index.html?rev=1914238&r1=1914237&r2=1914238&view=diff == --- tomcat/site/trunk/docs/index.html (original) +++ tomcat/site/trunk/docs/index.html Thu Nov 30 16:52:59 2023 @@ -1,5 +1,5 @@ -Apache Tomcat® - Welcome!https://www.apachecon.com/event-images/snippet.js";>http://tomcat.apache.org/";>Apache Tomcat®https://www.apache.org/foundation/contributing.html"; target ="_blank" class="pull-left">https://www.apache.org/images/SupportApache-small.png"; class="support-asf" alt="Support Apache">http://www.apache.org/"; target="_blank" class="pull-left">https://www.google.com/search"; method="get">GOApache TomcatHomeTaglibsMaven PluginDownloadWhich version?https://tomcat.apache.org/download-11.cgi";>Tomcat 11 (alpha)https://tomcat.apache.org/download-10.cgi";>Tomcat 10https://tomcat.apache.org/download-90.cgi";>Tomcat 9https://tomcat.apache.org/download-80.cgi";>Tomcat 8https://tomcat.apache.org/download-migration.cgi";>Tomcat Migration Tool for Jakarta EEhttps://tomcat.apache.org/download-connectors.cgi";>Tomcat Connectorshttps://tomcat.apache.org/download-native.cgi";>Tomcat Nativehttps://tomcat.apache.org/download-taglibs.cgi";>Taglibshttps://archive.apache.org/dist/tomcat/";>ArchivesDocumentationTomcat 11.0 (alpha)Tomcat 10.1Tomcat 9.0 Tomcat 8.5Tomcat ConnectorsTomcat Native 2Tomcat Native 1.2https://cwiki.apache.org/confluence/display/TOMCAT";>WikiMigration GuidePresentationshttps://cwiki.apache.org/confluence/x/Bi8lBg";>SpecificationsProblems?Security ReportsFind helphttps://cwiki.apache.org/confluence/display/TOMCAT/FAQ";>FAQMailing ListsBug DatabaseIRCGet InvolvedOverviewSource c odeBuildbothttps://cwiki.apache.org/confluence/x/vIPzBQ";>TranslationsToolsMediahttps://twitter.com/theapachetomcat";>Twitterhttps://www.youtube.com/c/ApacheTomcatOfficial";>YouTubehttps://blogs.apache.org/tomcat/";>BlogMiscWho We Arehttps://www.redbubble.com/people/comdev/works/30885254-apache-tomcat";>SwagHeritagehttp://www.apache.org";>Apache HomeResourcesContactLegalhttps://privacy.apache.org/policies/privacy-policy-public.html";>Privacyhttps://www.apache.org/foundation/contributing.html";>Support Apa chehttps://www.apache.org/foundation/sponsorship.html";>Sponsorshiphttp://www.apache.org/foundation/thanks.html";>Thankshttp://www.apache.org/licenses/";>LicenseContentApache Tomcat +Apache Tomcat® - Welcome!https://www.apachecon.com/event-images/snippet.js";>http://tomcat.apache.org/";>Apache Tomcat®https://www.apache.org/foundation/contributing.html"; target ="_blank" class="pull-left">https://www.apache.org/images/SupportApache-small.png"; class="support-asf" alt="Support Apache">http://www.apache.org/"; target="_blank" class="pull-left">https://www.google.com/search"; method="get">GOApache TomcatHomeTaglibsMaven PluginDownloadWhich version?https://tomcat.apache.org/download-11.cgi";>Tomcat 11 (alpha)https://tomcat.apache.org/download-10.cgi";>Tomcat 10https://tomcat.apache.org/download-90.cgi";>Tomcat 9https://tomcat.apache.org/download-80.cgi";>Tomcat 8https://tomcat.apache.org/download-migration.cgi";>Tomcat Migration Tool for Jakarta EEhttps://tomcat.apache.org/download-connectors.cgi";>Tomcat Connectorshttps://tomcat.apache.org/download-native.cgi";>Tomcat Nativehttps://tomcat.apache.org/download-taglibs.cgi";>Taglibshttps://archive.apache.org/dist/tomcat/";>ArchivesDocumentationTomcat 11.0 (alpha)Tomcat 10.1Tomcat 9.0 Tomcat 8.5UpgradingTomcat ConnectorsTomcat Native 2Tomcat Native 1.2https://cwiki.apache.org/confluence/display/TOMCAT";>WikiMigration GuidePresentationshttps://cwiki.apache.org/confluence/x/Bi8lBg";>SpecificationsProblems?Security ReportsFind helphttps://cwiki.apache.org/confluence/display/TOMCAT/FAQ";>FAQMailing ListsBug DatabaseIRCGet InvolvedOver viewSource codeBuildbothttps://cwiki.apache.org/confluence/x/vIPzBQ";>TranslationsToolsMediahttps://twitter.com/theapachetomcat";>Twitterhttps://www.youtube.com/c/ApacheTomcatOfficial";>YouTubehttps://blogs.apache.org/tomcat/";>BlogMiscWho We Arehttps://www.redbubble.com/people/comdev/works/30885254-apache-tomcat";>SwagHeritagehttp://www.apache.org";>Apache HomeResourcesContactLegalhttps://privacy.apache.org/policies/privacy-policy-public.html";>Privacyhttps://www.apa che.org/foundation/contributing.html">Support Apachehttps://www.apache.org/foundation/sponsorship.html";>Sponsorshiphttp://www.apache.org/foundation/thanks.html";>Thankshttp://www.apache.org/licenses/";>LicenseContentApache Tomcat The
(tomcat) branch 8.5.x updated: Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch
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 c07da30405 Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch c07da30405 is described below commit c07da304058b5f40250d26254fab8672b27f53e6 Author: Mark Thomas AuthorDate: Thu Nov 30 12:50:58 2023 + Fix BZ 68227. Ensure onComplete() is called if onError() calls dispatch --- java/org/apache/coyote/AsyncStateMachine.java | 1 + .../TestAsyncContextImplListenerOnComplete.java| 186 + webapps/docs/changelog.xml | 5 + 3 files changed, 192 insertions(+) diff --git a/java/org/apache/coyote/AsyncStateMachine.java b/java/org/apache/coyote/AsyncStateMachine.java index ba9822318e..6add187162 100644 --- a/java/org/apache/coyote/AsyncStateMachine.java +++ b/java/org/apache/coyote/AsyncStateMachine.java @@ -289,6 +289,7 @@ public class AsyncStateMachine { updateState(AsyncState.DISPATCHING); return SocketState.ASYNC_END; } else if (state == AsyncState.DISPATCHING) { +asyncCtxt.fireOnComplete(); updateState(AsyncState.DISPATCHED); asyncCtxt.decrementInProgressAsyncCount(); return SocketState.ASYNC_END; diff --git a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java new file mode 100644 index 00..2c2cd758a0 --- /dev/null +++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java @@ -0,0 +1,186 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.core; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Writer; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.servlet.AsyncContext; +import javax.servlet.AsyncEvent; +import javax.servlet.AsyncListener; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Assert; +import org.junit.Test; + +import org.apache.catalina.Context; +import org.apache.catalina.Wrapper; +import org.apache.catalina.startup.SimpleHttpClient; +import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.startup.TomcatBaseTest; + +public class TestAsyncContextImplListenerOnComplete extends TomcatBaseTest { + +/* + * https://bz.apache.org/bugzilla/show_bug.cgi?id=68227 + */ +@Test +public void testAfterNetworkErrorThenDispatch() throws Exception { +// Setup Tomcat instance +Tomcat tomcat = getTomcatInstance(); + +// No file system docBase required +Context ctx = tomcat.addContext("", null); + +// Latch to track that complete has been called +CountDownLatch completeLatch = new CountDownLatch(1); + +Wrapper servletWrapper = tomcat.addServlet("", "repro-servlet", new ReproServlet(completeLatch)); +servletWrapper.addMapping("/repro"); +servletWrapper.setAsyncSupported(true); +servletWrapper.setLoadOnStartup(1); + +ctx.addServletMappingDecoded("/", "repro-servlet"); + +tomcat.start(); +Thread.sleep(2000); + +triggerBrokenPipe(getPort()); + +Assert.assertTrue(completeLatch.await(30, TimeUnit.SECONDS)); +} + + +private void triggerBrokenPipe(int port) throws IOException, InterruptedException { +try (Socket socket = new Socket()) { +socket.setReceiveBufferSize(1); +socket.connect(new InetSocketAddress("localhost", port)); + +try (Writer writer = new OutputStreamWriter(socket.getOutputStream())) { +writer.write("GET /repro" + SimpleHttpClient.CRLF + +"Accept: text/event-stream" + SimpleHttpClient.CRLF + +
[Bug 68227] AsyncListener::onComplete is not called on network error if error listener calls dispatch
https://bz.apache.org/bugzilla/show_bug.cgi?id=68227 Mark Thomas changed: What|Removed |Added Resolution|--- |FIXED OS||All Status|NEW |RESOLVED --- Comment #1 from Mark Thomas --- Fixed in: - 11.0.x for 11.0.0-M15 onwards - 10.1.x for 10.1.17 onwards - 9.0.x for 9.0.84 onwards - 8.5.x for 8.5.97 onwards Thanks for the test case. I adapted it into a test for the Tomcat test suite. -- 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
Re: svn commit: r1914238 - in /tomcat/site/trunk: docs/index.html docs/upgrading.html xdocs/stylesheets/project.xml xdocs/upgrading.xml
On 30/11/2023 16:52, schu...@apache.org wrote: Author: schultz Date: Thu Nov 30 16:52:59 2023 New Revision: 1914238 URL: http://svn.apache.org/viewvc?rev=1914238&view=rev Log: Add an "Upgrading" page. Nice :) Mark - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: svn commit: r1914238 - in /tomcat/site/trunk: docs/index.html docs/upgrading.html xdocs/stylesheets/project.xml xdocs/upgrading.xml
Mark, On 11/30/23 12:07, Mark Thomas wrote: On 30/11/2023 16:52, schu...@apache.org wrote: Author: schultz Date: Thu Nov 30 16:52:59 2023 New Revision: 1914238 URL: http://svn.apache.org/viewvc?rev=1914238&view=rev Log: Add an "Upgrading" page. Nice :) There is some overlap with the "Migration" page. We may choose to merge these together at some point. I also wasn't sure precisely where to place the "Upgrading" link in the left-hand navigation menu. If anyone wants to move it, feel free to do so. -chris - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org