Bug 61393 - org.apache.tomcat.jni.TestSocketServer timeout failure on a fast computer
Summary: org.apache.tomcat.jni.TestSocketServer timeout failure on a fast computer
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Connectors (show other bugs)
Version: 9.0.0.M26
Hardware: PC All
: P2 minor (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-08 17:44 UTC by Konstantin Kolinko
Modified: 2017-08-31 08:52 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2017-08-08 17:44:48 UTC
Testing 9.0.0.M26 release candidate on a fast PC,
on Windows 10 with Tomcat Native dll in bin/native/.

I see the following failure in
TEST-org.apache.tomcat.jni.TestSocketServer.APR.txt

(The same result for NIO, NIO2 connectors as well, as this is a jni test - regardless of connector).

[[[
Testcase: testBlockingReadFromClientWithTimeout took 1,015 sec
	FAILED
Socket.timeoutSet failed (<1s) [985435824]
junit.framework.AssertionFailedError: Socket.timeoutSet failed (<1s) [985435824]
	at org.apache.tomcat.jni.TestSocketServer.testBlockingReadFromClientWithTimeout(TestSocketServer.java:99)
]]]


The value [985435824] is marginally smaller than expected 1000000000.

I wonder whether timeout is calculated from some earlier moment (that is - move "long start = System.nanoTime();" line earlier), or some arithmetic error is allowed here (introduce an error margin).

All other tests completed successfully.
Comment 1 Mark Thomas 2017-08-31 08:52:00 UTC
Fixed in trunk for 9.0.0.M27 onwards.

It appears the the root cause was that the resolution of System.nanoTime() is usually much greater than 1ns, particularly on Windows.