26
26
import javax .net .SocketFactory ;
27
27
import javax .net .ssl .SSLSocketFactory ;
28
28
29
+ import jdk .test .lib .Platform ;
29
30
import jdk .test .lib .util .FileUtils ;
30
31
31
32
/*
32
33
* @test
33
- * @bug 8256818 8257670
34
+ * @bug 8256818 8257670 8257884
34
35
* @summary Test that creating and closing SSL Sockets without bind/connect
35
36
* will not leave leaking socket file descriptors
36
37
* @library /test/lib
37
- * @run main/manual SSLSocketLeak
38
+ * @run main/othervm SSLSocketLeak
38
39
*/
39
40
// Note: this test is not reliable, run it manually.
40
41
public class SSLSocketLeak {
41
42
43
+ // number of sockets to open/close
42
44
private static final int NUM_TEST_SOCK = 500 ;
43
45
46
+ // percentage of accepted growth of open handles
47
+ private static final int OPEN_HANDLE_GROWTH_THRESHOLD = Platform .isWindows () ? 25 : 10 ;
48
+
44
49
public static void main (String [] args ) throws IOException {
45
50
long fds_start = FileUtils .getProcessHandleCount ();
46
51
System .out .println ("FDs at the beginning: " + fds_start );
@@ -53,7 +58,7 @@ public static void main(String[] args) throws IOException {
53
58
long fds_end = FileUtils .getProcessHandleCount ();
54
59
System .out .println ("FDs in the end: " + fds_end );
55
60
56
- if ((fds_end - fds_start ) > (NUM_TEST_SOCK / 10 )) {
61
+ if ((fds_end - fds_start ) > (NUM_TEST_SOCK / OPEN_HANDLE_GROWTH_THRESHOLD )) {
57
62
throw new RuntimeException ("Too many open file descriptors. Looks leaky." );
58
63
}
59
64
}
0 commit comments