JDK-8041924 : [TESTBUG] sun/net/www/http/ChunkedOutputStream/checkError.java fails on some systems
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7u79,emb-8u6,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: arm,ppc
  • Submitted: 2014-04-25
  • Updated: 2021-02-08
  • Resolved: 2016-06-13
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 7 JDK 8 JDK 9
7u311Fixed 8u301Fixed 9 b123Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
TESTFAIL:sun/net/www/http/ChunkedOutputStream/checkError.java
The test sun/net/www/http/ChunkedOutputStream/checkError.java was written to check the fix for JDK-5054016. It attempts to stream 1Mb of chunked data through an http connection to the server. The test expects that IOException was raised during 'write' operation when the server closes the connection. Both client and server work in one process in two different threads.

When the test is running with option -Xcomp we receive the following output:

gtee@emb-spb-imx53-hf-1:~$ $JAVA_HOME/bin/java -Xcomp -XX:+UseSerialGC -Dprofile.jre -cp JTwork/classes/sun/net/www/http/ChunkedOutputStream checkError
HTTP-client>Starting default Http-server
waiting server to be start
assigning 1024 to the chunk length
Server started
sending 1048576 bytes
Exception in thread "main" HTTP version: HTTP/1.1
User-Agent: Java/1.8.0_06-ea
Host: localhost:59534
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-type: application/x-www-form-urlencoded
Transfer-Encoding: chunked

receiving data
Server socket is closed
java.lang.RuntimeException: Test Failed: haven't received the expected IOException
        at checkError.testExit(checkError.java:121)
        at checkError.main(checkError.java:115)


With option -Xmixed:

gtee@emb-spb-imx53-hf-1:~$ $JAVA_HOME/bin/java -Xmixed -XX:+UseSerialGC -Dprofile.jre -cp JTwork/classes/sun/net/www/http/ChunkedOutputStream checkError
HTTP-client>Starting default Http-server
waiting server to be start
assigning 1024 to the chunk length
Server started
sending 1048576 bytes
HTTP version: HTTP/1.1
User-Agent: Java/1.8.0_06-ea
Host: localhost:60668
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-type: application/x-www-form-urlencoded
Transfer-Encoding: chunked

receiving data
Server socket is closed
TEST PASSED

The current test implementation very depends on two unaccounted factors:
1) size of underlying TCP buffers: 
# cat /proc/sys/net/ipv4/tcp_wmem
4096    16384   4001344
The maximum size of TCP buffer on the failed board is about 3.8Mb, that means 'write' operation in this test might not be blocked. Thus the client can easily write 1Mb to the server but it doesn't guarantee that something has been read on the server side.
2) thread scheduler:
It's not known how will cooperate client and server threads, the server thread may wake up to late when the client thread has finished its work.

One of the solution could be adding Thread.sleep(50) after every 'write' operation. It should take a chance to the server thread to do some work. However, the main problem in the test is its design, testing of so simple functionality could be done without involving network and threading functionality.



Comments
We see this failure in recent jdk8s as well, on linux x64, about 1% of the time.
04-04-2016

Updated bug summary and removed embedded label, since this has been reproduced on other test configuration.
15-08-2014

Also fails on linux-amd64 in jdk9 same binary run, see logs: #section:main ----------messages:(3/127)---------- command: main checkError reason: User specified action: run main/othervm/timeout=300 checkError elapsed time (seconds): 0.112 ----------System.out:(15/410)---------- HTTP-client>Starting default Http-server waiting server to be start assigning 1024 to the chunk length Server started sending 1048576 bytes HTTP version: HTTP/1.1 User-Agent: Java/1.9.0-ea Host: localhost:52009 Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Connection: keep-alive Content-type: application/x-www-form-urlencoded Transfer-Encoding: chunked receiving data Server socket is closed ----------System.err:(14/860)---------- java.lang.RuntimeException: Test Failed: haven't received the expected IOException at checkError.testExit(checkError.java:121) at checkError.main(checkError.java:115) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:484) at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94) at java.lang.Thread.run(Thread.java:745) JavaTest Message: Test threw exception: java.lang.RuntimeException: Test Failed: haven't received the expected IOException JavaTest Message: shutting down test STATUS:Failed.`main' threw exception: java.lang.RuntimeException: Test Failed: haven't received the expected IOException ----------rerun:(20/1643)*---------- DISPLAY=XXXX HOME=/Users/aurora \\ LANG=en_US.UTF-8 \\ PATH=/bin:/usr/bin \\ CLASSPATH=/Users/aurora/CommonData/jtreg/lib/javatest.jar:/Users/aurora/CommonData/jtreg/lib/jtreg.jar:/Users/aurora/sandbox/gresults/testoutput/jdk_net/JTwork/classes/sun/net/www/http/ChunkedOutputStream:/Users/aurora/sandbox/testbase/test/sun/net/www/http/ChunkedOutputStream:/Users/aurora/CommonData/jdk/lib/tools.jar \\ /Users/aurora/CommonData/jdk/bin/java \\ -Dtest.vm.opts='-ea -esa -Xmx512m' \\ -Dcompile.jdk=/Users/aurora/CommonData/jdk \\ -Dtest.src.path=/Users/aurora/sandbox/testbase/test/sun/net/www/http/ChunkedOutputStream \\ -Dtest.src=/Users/aurora/sandbox/testbase/test/sun/net/www/http/ChunkedOutputStream \\ -Dtest.tool.vm.opts='-J-ea -J-esa -J-Xmx512m' \\ -Dtest.class.path=/Users/aurora/sandbox/gresults/testoutput/jdk_net/JTwork/classes/sun/net/www/http/ChunkedOutputStream \\ -Dtest.timeout.factor=4.0 \\ -Dtest.classes=/Users/aurora/sandbox/gresults/testoutput/jdk_net/JTwork/classes/sun/net/www/http/ChunkedOutputStream \\ -Dtest.class.path.prefix=/Users/aurora/sandbox/gresults/testoutput/jdk_net/JTwork/classes/sun/net/www/http/ChunkedOutputStream:/Users/aurora/sandbox/testbase/test/sun/net/www/http/ChunkedOutputStream \\ -Dtest.jdk=/Users/aurora/CommonData/jdk \\ -Dtest.java.opts=-d64 \\ -Dtest.compiler.opts= \\ -ea -esa -Xmx512m -d64 \\ com.sun.javatest.regtest.MainWrapper /Users/aurora/sandbox/gresults/testoutput/jdk_net/JTwork/classes/sun/net/www/http/ChunkedOutputStream/checkError.jta result: Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Test Failed: haven't received the expected IOException test result: Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Test Failed: haven't received the expected IOException
20-05-2014

RULE sun/net/www/http/ChunkedOutputStream/checkError.java Exception java.lang.RuntimeException: Test Failed: haven't received the expected IOException
19-05-2014

Yes. Putting delays into the write side of the test or making it single threaded should fix it.
28-04-2014