tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1820194 - in /tomcat/trunk/webapps: docs/changelog.xml examples/WEB-INF/classes/async/AsyncStockServlet.java
Date Thu, 04 Jan 2018 20:11:04 GMT
Author: markt
Date: Thu Jan  4 20:11:04 2018
New Revision: 1820194

URL: http://svn.apache.org/viewvc?rev=1820194&view=rev
Log:
Partial fix for https://bz.apache.org/bugzilla/show_bug.cgi?id=61886
Ensure that multiple threads do not attempt to complete the AsyncContext if an I/O error occurs
in the stock ticker example Servlet.

Modified:
    tomcat/trunk/webapps/docs/changelog.xml
    tomcat/trunk/webapps/examples/WEB-INF/classes/async/AsyncStockServlet.java

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1820194&r1=1820193&r2=1820194&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Jan  4 20:11:04 2018
@@ -139,6 +139,11 @@
         <bug>61910</bug>: Clarify the meaning of the <code>allowLinking</code>
         option in the documentation web application. (markt)
       </fix>
+      <fix>
+        Partial fix for <bug>61886</bug>. Ensure that multiple threads do not
+        attempt to complete the <code>AsyncContext</code> if an I/O error occurs
+        in the stock ticker example Servlet. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Other">

Modified: tomcat/trunk/webapps/examples/WEB-INF/classes/async/AsyncStockServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/async/AsyncStockServlet.java?rev=1820194&r1=1820193&r2=1820194&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/WEB-INF/classes/async/AsyncStockServlet.java (original)
+++ tomcat/trunk/webapps/examples/WEB-INF/classes/async/AsyncStockServlet.java Thu Jan  4
20:11:04 2018
@@ -85,26 +85,24 @@ public class AsyncStockServlet extends H
         }
     }
 
-    public void writeStock(AsyncContext actx, Stock stock) {
+
+    public void writeStock(AsyncContext actx, Stock stock) throws IOException {
         HttpServletResponse response = (HttpServletResponse)actx.getResponse();
-        try {
-            PrintWriter writer = response.getWriter();
-            writer.write("STOCK#");//make client parsing easier
-            writer.write(stock.getSymbol());
-            writer.write("#");
-            writer.write(stock.getValueAsString());
-            writer.write("#");
-            writer.write(stock.getLastChangeAsString());
-            writer.write("#");
-            writer.write(String.valueOf(stock.getCnt()));
-            writer.write("\n");
-            writer.flush();
-            response.flushBuffer();
-        }catch (IOException x) {
-            try {actx.complete();}catch (Exception ignore){/* Ignore */}
-        }
+        PrintWriter writer = response.getWriter();
+        writer.write("STOCK#");//make client parsing easier
+        writer.write(stock.getSymbol());
+        writer.write("#");
+        writer.write(stock.getValueAsString());
+        writer.write("#");
+        writer.write(stock.getLastChangeAsString());
+        writer.write("#");
+        writer.write(String.valueOf(stock.getCnt()));
+        writer.write("\n");
+        writer.flush();
+        response.flushBuffer();
     }
 
+
     @Override
     public void onComplete(AsyncEvent event) throws IOException {
         if (clients.remove(event.getAsyncContext()) && clientcount.decrementAndGet()==0)
{



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message