author | prappo |
Fri, 13 Sep 2019 11:00:07 +0100 | |
changeset 58126 | 1def54255e93 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
1 |
/* |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
4 |
* |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
8 |
* |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
13 |
* accompanied this code). |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
14 |
* |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
18 |
* |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
21 |
* questions. |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
22 |
*/ |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
23 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
24 |
/* |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
25 |
* @test |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
26 |
* @library /test/lib |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
27 |
* lib/ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
28 |
* @run testng/othervm LdapTimeoutTest |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
29 |
* @bug 7094377 8000487 6176036 7056489 8151678 |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
30 |
* @summary Timeout tests for ldap |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
31 |
*/ |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
32 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
33 |
import org.testng.Assert; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
34 |
import org.testng.annotations.BeforeTest; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
35 |
import org.testng.annotations.Test; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
36 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
37 |
import javax.naming.Context; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
38 |
import javax.naming.NamingException; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
39 |
import javax.naming.directory.InitialDirContext; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
40 |
import javax.naming.directory.SearchControls; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
41 |
import java.io.IOException; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
42 |
import java.io.OutputStream; |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
43 |
import java.net.Socket; |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
44 |
import java.util.ArrayList; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
45 |
import java.util.Hashtable; |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
46 |
import java.util.List; |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
47 |
import java.util.Objects; |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
48 |
import java.util.concurrent.Callable; |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
49 |
import java.util.concurrent.CompletableFuture; |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
50 |
import java.util.concurrent.ExecutionException; |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
51 |
import java.util.concurrent.ExecutorService; |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
52 |
import java.util.concurrent.Executors; |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
53 |
import java.util.concurrent.Future; |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
54 |
import java.util.concurrent.FutureTask; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
55 |
import java.util.concurrent.SynchronousQueue; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
56 |
import java.util.concurrent.TimeUnit; |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
57 |
import java.util.concurrent.TimeoutException; |
25406
4814eec6a323
8047062: Improve diagnostic output in com/sun/jndi/ldap/LdapTimeoutTest.java
prappo
parents:
24519
diff
changeset
|
58 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
59 |
import static java.lang.String.format; |
25406
4814eec6a323
8047062: Improve diagnostic output in com/sun/jndi/ldap/LdapTimeoutTest.java
prappo
parents:
24519
diff
changeset
|
60 |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
4814eec6a323
8047062: Improve diagnostic output in com/sun/jndi/ldap/LdapTimeoutTest.java
prappo
parents:
24519
diff
changeset
|
61 |
import static java.util.concurrent.TimeUnit.NANOSECONDS; |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
62 |
import static jdk.test.lib.Utils.adjustTimeout; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
63 |
import static org.testng.Assert.assertTrue; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
64 |
import static org.testng.Assert.expectThrows; |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
65 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
66 |
public class LdapTimeoutTest { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
67 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
68 |
// ------ configure test timeouts here ------ |
27486
3549217e0897
8059311: com/sun/jndi/ldap/LdapTimeoutTest.java fails with exit_code == 0
prappo
parents:
25411
diff
changeset
|
69 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
70 |
/* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
71 |
* Practical representation of an infinite timeout. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
72 |
*/ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
73 |
private static final long INFINITY_MILLIS = adjustTimeout(20_000); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
74 |
/* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
75 |
* The acceptable variation in timeout measurements. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
76 |
*/ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
77 |
private static final long TOLERANCE = adjustTimeout( 3_500); |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
78 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
79 |
private static final long CONNECT_MILLIS = adjustTimeout( 3_000); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
80 |
private static final long READ_MILLIS = adjustTimeout(10_000); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
81 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
82 |
static { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
83 |
// a series of checks to make sure this timeouts configuration is |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
84 |
// consistent and the timeouts do not overlap |
24519
2fab99d91c4d
8042857: 14 stuck threads waiting for notification on LDAPRequest
robm
parents:
14342
diff
changeset
|
85 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
86 |
assert (TOLERANCE >= 0); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
87 |
// context creation |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
88 |
assert (2 * CONNECT_MILLIS + TOLERANCE < READ_MILLIS); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
89 |
// context creation immediately followed by search |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
90 |
assert (2 * CONNECT_MILLIS + READ_MILLIS + TOLERANCE < INFINITY_MILLIS); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
91 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
92 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
93 |
@BeforeTest |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
94 |
public void beforeTest() { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
95 |
startAuxiliaryDiagnosticOutput(); |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
96 |
} |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
97 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
98 |
/* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
99 |
* These are timeout tests and they are run in parallel to reduce the total |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
100 |
* amount of run time. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
101 |
* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
102 |
* Currently it doesn't seem possible to instruct JTREG to run TestNG test |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
103 |
* methods in parallel. That said, this JTREG test is still |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
104 |
* a "TestNG-flavored" test for the sake of having org.testng.Assert |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
105 |
* capability. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
106 |
*/ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
107 |
@Test |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
108 |
public void test() throws Exception { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
109 |
List<Future<?>> futures = new ArrayList<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
110 |
ExecutorService executorService = Executors.newCachedThreadPool(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
111 |
try { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
112 |
futures.add(executorService.submit(() -> { test1(); return null; })); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
113 |
futures.add(executorService.submit(() -> { test2(); return null; })); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
114 |
futures.add(executorService.submit(() -> { test3(); return null; })); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
115 |
futures.add(executorService.submit(() -> { test4(); return null; })); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
116 |
futures.add(executorService.submit(() -> { test5(); return null; })); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
117 |
futures.add(executorService.submit(() -> { test6(); return null; })); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
118 |
futures.add(executorService.submit(() -> { test7(); return null; })); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
119 |
} finally { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
120 |
executorService.shutdown(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
121 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
122 |
int failedCount = 0; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
123 |
for (var f : futures) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
124 |
try { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
125 |
f.get(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
126 |
} catch (ExecutionException e) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
127 |
failedCount++; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
128 |
e.getCause().printStackTrace(System.out); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
129 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
130 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
131 |
if (failedCount > 0) |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
132 |
throw new RuntimeException(failedCount + " (sub)tests failed"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
133 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
134 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
135 |
static void test1() throws Exception { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
136 |
Hashtable<Object, Object> env = new Hashtable<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
137 |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
138 |
// Here and in the other tests it's important to close the server as |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
139 |
// calling `thread.interrupt` from assertion may not be enough |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
140 |
// (depending on where the blocking call has stuck) |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
141 |
try (TestServer server = new NotBindableServer()) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
142 |
env.put(Context.PROVIDER_URL, urlTo(server)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
143 |
server.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
144 |
// Here and in the other tests joining done purely to reduce timing |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
145 |
// jitter. Commenting out or removing that should not make the test |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
146 |
// incorrect. (ServerSocket can accept connection as soon as it is |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
147 |
// bound, not need to call `accept` before that.) |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
148 |
server.starting().join(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
149 |
assertIncompletion(INFINITY_MILLIS, () -> new InitialDirContext(env)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
150 |
} |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
151 |
} |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
152 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
153 |
static void test2() throws Exception { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
154 |
Hashtable<Object, Object> env = new Hashtable<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
155 |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
156 |
env.put("com.sun.jndi.ldap.connect.timeout", String.valueOf(CONNECT_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
157 |
try (TestServer server = new BindableButNotReadableServer()) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
158 |
env.put(Context.PROVIDER_URL, urlTo(server)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
159 |
server.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
160 |
server.starting().join(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
161 |
InitialDirContext ctx = new InitialDirContext(env); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
162 |
SearchControls scl = new SearchControls(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
163 |
scl.setSearchScope(SearchControls.SUBTREE_SCOPE); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
164 |
assertIncompletion(INFINITY_MILLIS, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
165 |
() -> ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
166 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
167 |
} |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
168 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
169 |
static void test3() throws Exception { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
170 |
Hashtable<Object, Object> env = new Hashtable<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
171 |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
172 |
try (TestServer server = new BindableButNotReadableServer()) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
173 |
env.put(Context.PROVIDER_URL, urlTo(server)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
174 |
server.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
175 |
server.starting().join(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
176 |
InitialDirContext ctx = new InitialDirContext(env); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
177 |
SearchControls scl = new SearchControls(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
178 |
scl.setSearchScope(SearchControls.SUBTREE_SCOPE); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
179 |
assertIncompletion(INFINITY_MILLIS, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
180 |
() -> ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
181 |
} |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
182 |
} |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
183 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
184 |
static void test4() throws Exception { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
185 |
Hashtable<Object, Object> env = new Hashtable<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
186 |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
187 |
env.put("com.sun.jndi.ldap.connect.timeout", String.valueOf(CONNECT_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
188 |
env.put("com.sun.jndi.ldap.read.timeout", String.valueOf(READ_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
189 |
try (TestServer server = new NotBindableServer()) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
190 |
env.put(Context.PROVIDER_URL, urlTo(server)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
191 |
server.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
192 |
server.starting().join(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
193 |
Assert.ThrowingRunnable completion = |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
194 |
() -> assertCompletion(CONNECT_MILLIS, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
195 |
2 * CONNECT_MILLIS + TOLERANCE, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
196 |
() -> new InitialDirContext(env)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
197 |
NamingException e = expectThrows(NamingException.class, completion); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
198 |
String msg = e.getMessage(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
199 |
assertTrue(msg != null && msg.contains("timeout") |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
200 |
&& msg.contains(String.valueOf(CONNECT_MILLIS)), |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
201 |
msg); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
202 |
} |
24519
2fab99d91c4d
8042857: 14 stuck threads waiting for notification on LDAPRequest
robm
parents:
14342
diff
changeset
|
203 |
} |
2fab99d91c4d
8042857: 14 stuck threads waiting for notification on LDAPRequest
robm
parents:
14342
diff
changeset
|
204 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
205 |
static void test5() throws Exception { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
206 |
Hashtable<Object, Object> env = new Hashtable<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
207 |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
208 |
env.put("com.sun.jndi.ldap.connect.timeout", String.valueOf(CONNECT_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
209 |
env.put("com.sun.jndi.ldap.read.timeout", String.valueOf(READ_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
210 |
try (TestServer server = new BindableButNotReadableServer()) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
211 |
env.put(Context.PROVIDER_URL, urlTo(server)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
212 |
server.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
213 |
server.starting().join(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
214 |
InitialDirContext ctx = new InitialDirContext(env); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
215 |
SearchControls scl = new SearchControls(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
216 |
scl.setSearchScope(SearchControls.SUBTREE_SCOPE); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
217 |
Assert.ThrowingRunnable completion = |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
218 |
() -> assertCompletion(READ_MILLIS, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
219 |
READ_MILLIS + TOLERANCE, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
220 |
() -> ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
221 |
NamingException e = expectThrows(NamingException.class, completion); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
222 |
String msg = e.getMessage(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
223 |
assertTrue(msg != null && msg.contains("timeout") |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
224 |
&& msg.contains(String.valueOf(READ_MILLIS)), |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
225 |
msg); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
226 |
} |
32272
107a28901a7b
8046768: com/sun/jndi/ldap/LdapTimeoutTest.java fails intermittently
robm
parents:
29528
diff
changeset
|
227 |
} |
107a28901a7b
8046768: com/sun/jndi/ldap/LdapTimeoutTest.java fails intermittently
robm
parents:
29528
diff
changeset
|
228 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
229 |
static void test6() throws Exception { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
230 |
Hashtable<Object, Object> env = new Hashtable<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
231 |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
232 |
env.put("com.sun.jndi.ldap.connect.timeout", String.valueOf(CONNECT_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
233 |
env.put("com.sun.jndi.ldap.read.timeout", String.valueOf(READ_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
234 |
try (TestServer server = new NotBindableServer()) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
235 |
env.put(Context.PROVIDER_URL, urlTo(server)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
236 |
server.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
237 |
server.starting().join(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
238 |
Assert.ThrowingRunnable completion = |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
239 |
() -> assertCompletion(CONNECT_MILLIS, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
240 |
2 * CONNECT_MILLIS + TOLERANCE, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
241 |
() -> new InitialDirContext(env)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
242 |
NamingException e = expectThrows(NamingException.class, completion); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
243 |
String msg = e.getMessage(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
244 |
assertTrue(msg != null && msg.contains("timeout") |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
245 |
&& msg.contains(String.valueOf(CONNECT_MILLIS)), |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
246 |
msg); |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
247 |
} |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
248 |
} |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
249 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
250 |
static void test7() throws Exception { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
251 |
// 8000487: Java JNDI connection library on ldap conn is |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
252 |
// not honoring configured timeout |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
253 |
Hashtable<Object, Object> env = new Hashtable<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
254 |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
255 |
env.put("com.sun.jndi.ldap.connect.timeout", String.valueOf(CONNECT_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
256 |
env.put("com.sun.jndi.ldap.read.timeout", String.valueOf(READ_MILLIS)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
257 |
env.put(Context.SECURITY_AUTHENTICATION, "simple"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
258 |
env.put(Context.SECURITY_PRINCIPAL, "user"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
259 |
env.put(Context.SECURITY_CREDENTIALS, "password"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
260 |
try (TestServer server = new NotBindableServer()) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
261 |
env.put(Context.PROVIDER_URL, urlTo(server)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
262 |
server.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
263 |
server.starting().join(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
264 |
Assert.ThrowingRunnable completion = |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
265 |
() -> assertCompletion(CONNECT_MILLIS, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
266 |
2 * CONNECT_MILLIS + TOLERANCE, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
267 |
() -> new InitialDirContext(env)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
268 |
NamingException e = expectThrows(NamingException.class, completion); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
269 |
String msg = e.getMessage(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
270 |
assertTrue(msg != null && msg.contains("timeout") |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
271 |
&& msg.contains(String.valueOf(CONNECT_MILLIS)), |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
272 |
msg); |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
273 |
} |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
274 |
} |
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
275 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
276 |
// ------ test stub servers ------ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
277 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
278 |
static class TestServer extends BaseLdapServer { |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
279 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
280 |
private final CompletableFuture<Void> starting = new CompletableFuture<>(); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
281 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
282 |
TestServer() throws IOException { } |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
283 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
284 |
@Override |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
285 |
protected void beforeAcceptingConnections() { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
286 |
starting.completeAsync(() -> null); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
287 |
} |
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
288 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
289 |
public CompletableFuture<Void> starting() { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
290 |
return starting.copy(); |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
291 |
} |
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
292 |
} |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
293 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
294 |
static class BindableButNotReadableServer extends TestServer { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
295 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
296 |
BindableButNotReadableServer() throws IOException { } |
14184
5553422ece67
8000487: Java JNDI connection library on ldap conn is not honoring configured timeout
robm
parents:
diff
changeset
|
297 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
298 |
private static final byte[] bindResponse = { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
299 |
0x30, 0x0C, 0x02, 0x01, 0x01, 0x61, 0x07, 0x0A, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
300 |
0x01, 0x00, 0x04, 0x00, 0x04, 0x00 |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
301 |
}; |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
302 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
303 |
@Override |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
304 |
protected void handleRequest(Socket socket, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
305 |
LdapMessage msg, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
306 |
OutputStream out) |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
307 |
throws IOException { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
308 |
switch (msg.getOperation()) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
309 |
case BIND_REQUEST: |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
310 |
out.write(bindResponse); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
311 |
out.flush(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
312 |
default: |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
313 |
break; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
314 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
315 |
} |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
316 |
} |
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
317 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
318 |
static class NotBindableServer extends TestServer { |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
319 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
320 |
NotBindableServer() throws IOException { } |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
321 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
322 |
@Override |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
323 |
protected void beforeConnectionHandled(Socket socket) { |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
324 |
try { |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
325 |
TimeUnit.DAYS.sleep(Integer.MAX_VALUE); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
326 |
} catch (InterruptedException e) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
327 |
Thread.currentThread().interrupt(); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
328 |
} |
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
329 |
} |
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
330 |
} |
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
331 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
332 |
// ------ timeouts check utilities ------ |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
333 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
334 |
/* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
335 |
* Asserts that the specified executable yields a result or an exception |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
336 |
* within the specified time frame. Interrupts the executable |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
337 |
* unconditionally. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
338 |
* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
339 |
* If the executable yields a result or an exception within the specified |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
340 |
* time frame, the result will be returned and the exception will be |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
341 |
* rethrown respectively in a transparent fashion as if the executable was |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
342 |
* executed directly. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
343 |
*/ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
344 |
public static <T> T assertCompletion(long loMillis, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
345 |
long hiMillis, |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
346 |
Callable<T> code) |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
347 |
throws Throwable { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
348 |
if (loMillis < 0 || hiMillis < 0 || loMillis > hiMillis) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
349 |
throw new IllegalArgumentException("loMillis=" + loMillis + |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
350 |
", hiMillis=" + hiMillis); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
351 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
352 |
Objects.requireNonNull(code); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
353 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
354 |
// this queue acts both as an exchange point and a barrier |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
355 |
SynchronousQueue<Long> startTime = new SynchronousQueue<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
356 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
357 |
Callable<T> wrappedTask = () -> { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
358 |
// by the time this value reaches the "stopwatch" thread it might be |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
359 |
// well outdated and that's okay, we will adjust the wait time |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
360 |
startTime.put(System.nanoTime()); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
361 |
return code.call(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
362 |
}; |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
363 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
364 |
FutureTask<T> task = new FutureTask<>(wrappedTask); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
365 |
Thread t = new Thread(task); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
366 |
t.start(); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
367 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
368 |
final long startNanos; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
369 |
try { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
370 |
startNanos = startTime.take(); // (1) wait for the initial time mark |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
371 |
} catch (Throwable e) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
372 |
t.interrupt(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
373 |
throw e; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
374 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
375 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
376 |
final long waitTime = hiMillis - |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
377 |
NANOSECONDS.toMillis(System.nanoTime() - startNanos); // (2) adjust wait time |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
378 |
|
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
379 |
try { |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
380 |
T r = task.get(waitTime, MILLISECONDS); // (3) wait for the task to complete |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
381 |
long elapsed = NANOSECONDS.toMillis(System.nanoTime() - startNanos); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
382 |
if (elapsed < loMillis || elapsed > hiMillis) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
383 |
throw new RuntimeException(format( |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
384 |
"After %s ms. (waitTime %s ms.) returned result '%s'", elapsed, waitTime, r)); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
385 |
} |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
386 |
return r; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
387 |
} catch (ExecutionException e) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
388 |
long elapsed = NANOSECONDS.toMillis(System.nanoTime() - startNanos); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
389 |
if (elapsed < loMillis || elapsed > hiMillis) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
390 |
throw new RuntimeException(format( |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
391 |
"After %s ms. (waitTime %s ms.) thrown exception", elapsed, waitTime), e); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
392 |
} |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
393 |
throw e.getCause(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
394 |
} catch (TimeoutException e) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
395 |
// We trust timed get not to throw TimeoutException prematurely |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
396 |
// (i.e. before the wait time elapses) |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
397 |
long elapsed = NANOSECONDS.toMillis(System.nanoTime() - startNanos); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
398 |
throw new RuntimeException(format( |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
399 |
"After %s ms. (waitTime %s ms.) is incomplete", elapsed, waitTime)); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
400 |
} finally { |
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
401 |
t.interrupt(); |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
402 |
} |
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
403 |
} |
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
404 |
|
58126
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
405 |
/* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
406 |
* Asserts that the specified executable yields no result and no exception |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
407 |
* for at least the specified amount of time. Interrupts the executable |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
408 |
* unconditionally. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
409 |
*/ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
410 |
public static void assertIncompletion(long millis, Callable<?> code) |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
411 |
throws Exception |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
412 |
{ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
413 |
if (millis < 0) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
414 |
throw new IllegalArgumentException("millis=" + millis); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
415 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
416 |
Objects.requireNonNull(code); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
417 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
418 |
// this queue acts both as an exchange point and a barrier |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
419 |
SynchronousQueue<Long> startTime = new SynchronousQueue<>(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
420 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
421 |
Callable<?> wrappedTask = () -> { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
422 |
// by the time this value reaches the "stopwatch" thread it might be |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
423 |
// well outdated and that's okay, we will adjust the wait time |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
424 |
startTime.put(System.nanoTime()); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
425 |
return code.call(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
426 |
}; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
427 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
428 |
FutureTask<?> task = new FutureTask<>(wrappedTask); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
429 |
Thread t = new Thread(task); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
430 |
t.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
431 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
432 |
final long startNanos; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
433 |
try { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
434 |
startNanos = startTime.take(); // (1) wait for the initial time mark |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
435 |
} catch (Throwable e) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
436 |
t.interrupt(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
437 |
throw e; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
438 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
439 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
440 |
final long waitTime = millis - |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
441 |
NANOSECONDS.toMillis(System.nanoTime() - startNanos); // (2) adjust wait time |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
442 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
443 |
try { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
444 |
Object r = task.get(waitTime, MILLISECONDS); // (3) wait for the task to complete |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
445 |
long elapsed = NANOSECONDS.toMillis(System.nanoTime() - startNanos); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
446 |
if (elapsed < waitTime) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
447 |
throw new RuntimeException(format( |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
448 |
"After %s ms. (waitTime %s ms.) returned result '%s'", elapsed, waitTime, r)); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
449 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
450 |
} catch (ExecutionException e) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
451 |
long elapsed = NANOSECONDS.toMillis(System.nanoTime() - startNanos); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
452 |
if (elapsed < waitTime) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
453 |
throw new RuntimeException(format( |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
454 |
"After %s ms. (waitTime %s ms.) thrown exception", elapsed, waitTime), e); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
455 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
456 |
} catch (TimeoutException expected) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
457 |
} finally { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
458 |
t.interrupt(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
459 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
460 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
461 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
462 |
// ------ miscellaneous utilities ------ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
463 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
464 |
private static String urlTo(TestServer server) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
465 |
String hostAddress = server.getInetAddress().getHostAddress(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
466 |
String addr; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
467 |
if (hostAddress.contains(":")) { // IPv6 |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
468 |
addr = '[' + hostAddress + ']'; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
469 |
} else { // IPv4 |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
470 |
addr = hostAddress; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
471 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
472 |
return "ldap://" + addr + ":" + server.getPort(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
473 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
474 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
475 |
/* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
476 |
* A diagnostic aid that might help with debugging timeout issues. The idea |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
477 |
* is to continuously measure accuracy and responsiveness of the system that |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
478 |
* runs this test. If the system is overwhelmed (with something else), it |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
479 |
* might affect the test run. At the very least we will have traces of that |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
480 |
* in the logs. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
481 |
* |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
482 |
* This utility does not automatically scale up test timeouts, it simply |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
483 |
* gathers information. |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
484 |
*/ |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
485 |
private static void startAuxiliaryDiagnosticOutput() { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
486 |
System.out.printf("Starting diagnostic output (probe)%n"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
487 |
Thread t = new Thread(() -> { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
488 |
for (int i = 0; ; i = ((i % 20) + 1)) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
489 |
// 500, 1_000, 1_500, ..., 9_500, 10_000, 500, 1_000, ... |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
490 |
long expected = i * 500; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
491 |
long start = System.nanoTime(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
492 |
try { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
493 |
MILLISECONDS.sleep(expected); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
494 |
} catch (InterruptedException e) { |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
495 |
return; |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
496 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
497 |
long stop = System.nanoTime(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
498 |
long actual = NANOSECONDS.toMillis(stop - start); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
499 |
System.out.printf("(probe) expected [ms.]: %s, actual [ms.]: %s%n", |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
500 |
expected, actual); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
501 |
|
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
502 |
} |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
503 |
}, "probe"); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
504 |
t.setDaemon(true); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
505 |
t.start(); |
1def54255e93
8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect
prappo
parents:
47216
diff
changeset
|
506 |
} |
27935
80c148fb46c5
8065238: javax.naming.NamingException after upgrade to JDK 8
robm
parents:
27486
diff
changeset
|
507 |
} |