Skip to content

Commit 28b6c7d

Browse files
committed
Add support for NIO2 connector in TestLargeClientHello
1 parent 08aa172 commit 28b6c7d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

java/org/apache/tomcat/util/net/SecureNio2Channel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@ protected SSLEngineResult handshakeUnwrap() throws IOException {
590590
// call unwrap
591591
getBufHandler().configureReadBufferForWrite();
592592
result = sslEngine.unwrap(netInBuffer, getBufHandler().getReadBuffer());
593+
if (log.isDebugEnabled() && result.getStatus() == SSLEngineResult.Status.BUFFER_UNDERFLOW) {
594+
log.debug(sm.getString("channel.nio.ssl.handshakeUnwrapBufferUnderflow"));
595+
}
593596
/*
594597
* ByteBuffer.compact() is an optional method but netInBuffer is created from either ByteBuffer.allocate()
595598
* or ByteBuffer.allocateDirect() and the ByteBuffers returned by those methods do implement compact(). The

test/org/apache/tomcat/util/net/TestLargeClientHello.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ public void testLargeClientHelloWithSessionResumption() throws Exception {
6565

6666
TesterSupport.initSsl(tomcat, keystoreFile.getAbsolutePath(), false);
6767

68-
try (LogCapture logCapture = attachLogCapture(Level.FINE, "org.apache.tomcat.util.net.SecureNioChannel")) {
68+
try (LogCapture nioCapture = attachLogCapture(Level.FINE,
69+
"org.apache.tomcat.util.net.SecureNioChannel");
70+
LogCapture nio2Capture = attachLogCapture(Level.FINE,
71+
"org.apache.tomcat.util.net.SecureNio2Channel")) {
6972

7073
tomcat.start();
7174

@@ -77,8 +80,10 @@ public void testLargeClientHelloWithSessionResumption() throws Exception {
7780
Assert.assertTrue(getUrl(url).toString().contains("Hello World"));
7881
Assert.assertTrue(getUrl(url).toString().contains("Hello World"));
7982

80-
Assert.assertTrue(logCapture.containsText(
83+
Assert.assertTrue(nioCapture.containsText(
8184
TomcatBaseTest.getKeyFromPropertiesFile("org.apache.tomcat.util.net",
85+
"channel.nio.ssl.handshakeUnwrapBufferUnderflow")) || nio2Capture.containsText(
86+
TomcatBaseTest.getKeyFromPropertiesFile("org.apache.tomcat.util.net",
8287
"channel.nio.ssl.handshakeUnwrapBufferUnderflow")));
8388
}
8489

0 commit comments

Comments
 (0)