8037360: java/nio/channels/SocketChannel/Connect.java fails intermittently
Reviewed-by: alanb
This commit is contained in:
parent
be2c5ba74b
commit
f9295881a8
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4650679
|
||||
* @bug 4650679 8037360
|
||||
* @summary Unit test for socket channels
|
||||
* @library ..
|
||||
*/
|
||||
@ -42,9 +42,7 @@ public class Connect {
|
||||
test1(echoServer);
|
||||
}
|
||||
try {
|
||||
TestServers.RefusingServer refusingServer
|
||||
= TestServers.RefusingServer.startNewServer();
|
||||
test1(refusingServer);
|
||||
test1(TestServers.RefusingServer.newRefusingServer());
|
||||
throw new Exception("Refused connection throws no exception");
|
||||
} catch (ConnectException ce) {
|
||||
// Correct result
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -80,13 +80,12 @@ public class TestServers {
|
||||
return address;
|
||||
}
|
||||
|
||||
public static RefusingServer startNewServer() throws IOException {
|
||||
ServerSocket socket = new ServerSocket(0, 100,
|
||||
InetAddress.getLocalHost());
|
||||
RefusingServer server = new RefusingServer(socket.getInetAddress(),
|
||||
socket.getLocalPort());
|
||||
socket.close();
|
||||
return server;
|
||||
public static RefusingServer newRefusingServer() throws IOException {
|
||||
// The port 1 is reserved for TCPMUX(RFC 1078), which is seldom used,
|
||||
// and it's not used on all the test platform through JPRT.
|
||||
// So we choose to use it as a refusing "server"'s "listen" port,
|
||||
// it's much more stable than "open->close a server socket".
|
||||
return new RefusingServer(InetAddress.getLocalHost(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user