This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new b897bcb Use a much larger timeout to avoid false test failures
b897bcb is described below
commit b897bcbe0d76eabbc9eb1842c54385d20c7fbaa2
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 9 09:36:15 2019 +0100
Use a much larger timeout to avoid false test failures
---
test/org/apache/tomcat/jni/TestSocketServer.java | 25 +++++++++++-------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/test/org/apache/tomcat/jni/TestSocketServer.java
b/test/org/apache/tomcat/jni/TestSocketServer.java
index d1ea90d..059add3 100644
--- a/test/org/apache/tomcat/jni/TestSocketServer.java
+++ b/test/org/apache/tomcat/jni/TestSocketServer.java
@@ -24,30 +24,27 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-/**
+/*
* Tests for server-side sockets.
+ *
+ * While System.nanotime() is available and may have a resolution of ~100ns on
+ * some platforms, those same platforms do not use as precise a timer for
socket
+ * timeouts. Therefore, a much larger error margin (100ms) is used.
+ *
+ * It is known that this larger error margin is required for Windows 10. It may
+ * be worth revisiting the choice of error margin once that platform is no
+ * longer supported.
*/
public class TestSocketServer extends AbstractJniTest {
private static final String HOST = "localhost";
- private static final long ERROR_MARGIN;
+ // 100ms == 100,000,000ns
+ private static final long ERROR_MARGIN = 100000000;
private int port = 0;
private long serverSocket = 0;
private long clientSocket = 0;
- // Determine the resolution of System.nanoTime() so an appropriate error
- // margin can be used in tests that use nanoTime()
- static {
- long start = System.nanoTime();
- long end = System.nanoTime();
- while (end == start) {
- end = System.nanoTime();
- }
- ERROR_MARGIN = 2 * (end - start);
- }
-
-
@Before
public void init() throws Exception {
long serverPool = Pool.create(0);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]