Skip to content

Commit

Permalink
[Wisp] Revert back TestWispSocketLeakWhenConnectTimeout.java
Browse files Browse the repository at this point in the history
Summary: This test needs a timeout.

Test Plan: The test itself

Reviewers: shiyue.xw, lei.yul

Issue: https://aone.alibaba-inc.com/task/27728272

CR: https://code.aone.alibaba-inc.com/xcode/jdk11/codereview/2982335
  • Loading branch information
zhengxiaolinX authored and Sere-Fu committed Aug 19, 2021
1 parent d237fb7 commit 28eb564
Showing 1 changed file with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,21 @@
* @library /lib/testlibrary
* @summary test the fix to fd leakage when socket connect timeout
* @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true TestWispSocketLeakWhenConnectTimeout
*/
*/

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.Properties;

import static jdk.testlibrary.Asserts.assertTrue;

public class TestWispSocketLeakWhenConnectTimeout {

static Properties p;
static String socketAddr;
static {
p = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Properties>() {
public Properties run() {
return System.getProperties();
}
}
);
socketAddr = (String)p.get("test.wisp.socketAddress");
if (socketAddr == null) {
socketAddr = "www.example.com";
}
}

public static void main(String[] args) throws IOException {
Socket so = new Socket();
boolean timeout = false;
try {
so.connect(new InetSocketAddress(socketAddr, 80), 5);
so.connect(new InetSocketAddress("www.example.com", 80), 5);
} catch (SocketTimeoutException e) {
assertTrue(so.isClosed());
timeout = true;
Expand Down

0 comments on commit 28eb564

Please sign in to comment.