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 2017/07/17 20:53:20 UTC

svn commit: r1802210 - in /tomcat/trunk/test/org/apache/coyote/http2: TestHttp2Section_4_2.java TestHttp2Section_5_1.java TestHttp2Section_6_2.java

Author: markt
Date: Mon Jul 17 20:53:20 2017
New Revision: 1802210

URL: http://svn.apache.org/viewvc?rev=1802210&view=rev
Log:
Add handling for are now, hopefully, consistent connection reset results for NIO2 on Windows.

Modified:
    tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
    tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
    tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_2.java

Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java?rev=1802210&r1=1802209&r2=1802210&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java Mon Jul 17 20:53:20 2017
@@ -16,9 +16,15 @@
  */
 package org.apache.coyote.http2;
 
+import java.net.SocketException;
+
 import org.junit.Assert;
+import org.junit.Assume;
 import org.junit.Test;
 
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.startup.Tomcat;
+
 /**
  * Unit tests for Section 4.2 of
  * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
@@ -55,11 +61,22 @@ public class TestHttp2Section_4_2 extend
 
         os.write(settings);
 
-        // Read GOAWAY frame
-        parser.readFrame(true);
+        try {
+            // Read GOAWAY frame
+            parser.readFrame(true);
+
+            Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+                    "0-Goaway-[1]-[" + Http2Error.FRAME_SIZE_ERROR.getCode() + "]-["));
+        } catch (SocketException se) {
+            // On some platform / Connector combinations (e.g. Windows / NIO2),
+            // the TCP connection close will be processed before the client gets
+            // a chance to read the connection close frame.
+            Tomcat tomcat = getTomcatInstance();
+            Connector connector = tomcat.getConnector();
 
-        Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
-                "0-Goaway-[1]-[" + Http2Error.FRAME_SIZE_ERROR.getCode() + "]-["));
+            Assume.assumeTrue("This test is only expected to trigger an exception with NIO2",
+                    connector.getProtocolHandlerClassName().contains("Nio2"));
+        }
     }
 
     @Test

Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java?rev=1802210&r1=1802209&r2=1802210&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_1.java Mon Jul 17 20:53:20 2017
@@ -16,11 +16,16 @@
  */
 package org.apache.coyote.http2;
 
+import java.net.SocketException;
 import java.nio.ByteBuffer;
 
 import org.junit.Assert;
+import org.junit.Assume;
 import org.junit.Test;
 
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.startup.Tomcat;
+
 /**
  * Unit tests for Section 5.§ of
  * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
@@ -135,11 +140,22 @@ public class TestHttp2Section_5_1 extend
         buildSimpleGetRequestPart1(frameHeader, headersPayload, 4);
         writeFrame(frameHeader, headersPayload);
 
-        // headers
-        parser.readFrame(true);
-
-        Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
-                "0-Goaway-[1]-[" + Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+        try {
+            // headers
+            parser.readFrame(true);
+
+            Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+                    "0-Goaway-[1]-[" + Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+        } catch (SocketException se) {
+            // On some platform / Connector combinations (e.g. Windows / NIO2),
+            // the TCP connection close will be processed before the client gets
+            // a chance to read the connection close frame.
+            Tomcat tomcat = getTomcatInstance();
+            Connector connector = tomcat.getConnector();
+
+            Assume.assumeTrue("This test is only expected to trigger an exception with NIO2",
+                    connector.getProtocolHandlerClassName().contains("Nio2"));
+        }
     }
 
 

Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_2.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_2.java?rev=1802210&r1=1802209&r2=1802210&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_2.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_2.java Mon Jul 17 20:53:20 2017
@@ -16,11 +16,16 @@
  */
 package org.apache.coyote.http2;
 
+import java.net.SocketException;
 import java.nio.ByteBuffer;
 
 import org.junit.Assert;
+import org.junit.Assume;
 import org.junit.Test;
 
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.startup.Tomcat;
+
 /**
  * Unit tests for Section 6.2 of
  * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
@@ -41,11 +46,22 @@ public class TestHttp2Section_6_2 extend
         buildSimpleGetRequestPart1(frameHeader, headersPayload, 0);
         writeFrame(frameHeader, headersPayload);
 
-        // Go away
-        parser.readFrame(true);
-
-        Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
-                "0-Goaway-[1]-[" + Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+        try {
+            // Go away
+            parser.readFrame(true);
+
+            Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+                    "0-Goaway-[1]-[" + Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+        } catch (SocketException se) {
+            // On some platform / Connector combinations (e.g. Windows / NIO2),
+            // the TCP connection close will be processed before the client gets
+            // a chance to read the connection close frame.
+            Tomcat tomcat = getTomcatInstance();
+            Connector connector = tomcat.getConnector();
+
+            Assume.assumeTrue("This test is only expected to trigger an exception with NIO2",
+                    connector.getProtocolHandlerClassName().contains("Nio2"));
+        }
     }
 
 



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