JDK-8239052 : java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java failed with BufferUnderflowException against TLSv1.3
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-02-14
  • Updated: 2020-02-27
  • Resolved: 2020-02-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b12Fixed
Related Reports
Relates :  
Description
Updated AbstractSSLTubeTest.java as the below,
diff -r 87651cb03ebc test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java
--- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java	Thu Feb 13 13:43:09 2020 -0800
+++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java	Fri Feb 14 10:24:28 2020 +0800
@@ -225,7 +225,7 @@
         SSLContext context = (new SimpleSSLContext()).get();
         SSLEngine engine = context.createSSLEngine();
         SSLParameters params = context.getSupportedSSLParameters();
-        params.setProtocols(new String[]{"TLSv1.2"}); // TODO: This is essential. Needs to be protocol impl
+        params.setProtocols(new String[]{"TLSv1.3"}); // TODO: This is essential. Needs to be protocol impl
         if (client) {
             params.setApplicationProtocols(new String[]{"proto1", "proto2"}); // server will choose proto2
         } else {

java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java failed with BufferUnderflowException.
EchoTube got subscriber: SSLTube(jdk.internal.net.http.SSLEchoTubeTest$LateBindingTube@6ac28d6d)
EchoTube got request: 1
EchoTube: queue empty, requested=0, demand=1, transmitted=0
EchoTube request: 6
EndSubscriber request 13
Submitting 600 buffer arrays
LoopCount should be 480000
Finished submission. Waiting for loopback
EchoTube add 16367 [requested:6, queue:0]
EchoTube processing item, requested=6, demand=1, transmitted=0
EchoTube processing 16367
EchoTube got request: 1
EchoTube: queue empty, requested=5, demand=1, transmitted=1
EchoTube: queue empty, requested=4, demand=1, transmitted=1
EchoTube request: 3 [requested:3, queue:0, unfulfilled:3]
EchoTube add 15633 [requested:6, queue:0]
EchoTube processing item, requested=6, demand=1, transmitted=1
EchoTube processing 15633
EndSubscriber: 0
EndSubscriber onNext 16367
EchoTube: queue empty, requested=5, demand=0, transmitted=2
EndSubscriber onError java.nio.BufferUnderflowException
All bytes received: calling publisher.close()
EchoTube add 6400 [requested:4, queue:0]
EchoTube processing item, requested=4, demand=0, transmitted=2
EchoTube no demand
test jdk.internal.net.http.SSLEchoTubeTest.runWithEchoServer(): failure
java.util.concurrent.CompletionException: java.nio.BufferUnderflowException
	at java.base/java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:412)
	at java.base/java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2108)
	at java.net.http/jdk.internal.net.http.AbstractSSLTubeTest.run(AbstractSSLTubeTest.java:106)
	at java.net.http/jdk.internal.net.http.SSLEchoTubeTest.runWithEchoServer(SSLEchoTubeTest.java:58)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
	at org.testng.TestRunner.privateRun(TestRunner.java:773)
	at org.testng.TestRunner.run(TestRunner.java:623)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
	at org.testng.SuiteRunner.run(SuiteRunner.java:259)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
	at org.testng.TestNG.run(TestNG.java:1018)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:94)
	at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:54)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.nio.BufferUnderflowException
	at java.base/java.nio.Buffer.nextGetIndex(Buffer.java:696)
	at java.base/java.nio.HeapByteBuffer.getLong(HeapByteBuffer.java:509)
	at java.net.http/jdk.internal.net.http.AbstractSSLTubeTest$EndSubscriber.onNext(AbstractSSLTubeTest.java:179)
	at java.net.http/jdk.internal.net.http.AbstractSSLTubeTest$EndSubscriber.onNext(AbstractSSLTubeTest.java:126)
	at java.net.http/jdk.internal.net.http.common.SSLTube$DelegateWrapper.onNext(SSLTube.java:202)
	at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onNext(SSLTube.java:484)
	at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onNext(SSLTube.java:287)
	at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run1(SubscriberWrapper.java:316)
	at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run(SubscriberWrapper.java:259)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:232)
	at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:198)
	at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader.processData(SSLFlowDelegate.java:434)
	at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader$ReaderDownstreamPusher.run(SSLFlowDelegate.java:264)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	... 1 more

===============================================
java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java
Total tests run: 1, Failures: 1, Skips: 0
===============================================

EchoTube add 6400 [requested:4, queue:1]
EchoTube processing item, requested=4, demand=0, transmitted=2
EchoTube no demand
EchoTube got request: 1
EchoTube processing item, requested=4, demand=1, transmitted=2
EchoTube processing 6400
EchoTube add 6400 [requested:4, queue:1]
EchoTube processing item, requested=3, demand=0, transmitted=3
EchoTube no demand
EchoTube processing item, requested=3, demand=0, transmitted=3
EchoTube no demand
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/2dcefc0b8a6d User: dfuchs Date: 2020-02-24 17:20:55 +0000
24-02-2020

The exception occurs because the buffers are not split at 8 bytes boundary. The code tries to read a long but the long is split over several buffers.
20-02-2020

However java/net/httpclient/whitebox/SSLTubeTestDriver.java passed with the above updated AbstractSSLTubeTest.java.
14-02-2020

The attached SSLEchoTubeTestDriver.jtr contains the full logs.
14-02-2020