summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaikiran Pai <jpai@openjdk.org>2024-03-02 01:44:25 +0000
committerJaikiran Pai <jpai@openjdk.org>2024-03-02 01:44:25 +0000
commita9c17a22ca8e64d12e28e272e3f4845297290854 (patch)
tree213d7df31b17f7e5c566ecd21811f33146f21810
parent7f02f07f754c942735ba15d70858cd1661a658c0 (diff)
8327108: compiler.lib.ir_framework.shared.TestFrameworkSocket should listen on loopback address only
Reviewed-by: chagedorn, kvn
-rw-r--r--test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java b/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java
index 988df309718..c59f432f5ff 100644
--- a/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java
+++ b/test/hotspot/jtreg/compiler/lib/ir_framework/shared/TestFrameworkSocket.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2024, 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
@@ -29,6 +29,8 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutionException;
@@ -47,7 +49,6 @@ public class TestFrameworkSocket implements AutoCloseable {
private static final int SERVER_PORT = Integer.getInteger(SERVER_PORT_PROPERTY, -1);
private static final boolean REPRODUCE = Boolean.getBoolean("Reproduce");
- private static final String HOSTNAME = null;
private static Socket clientSocket = null;
private static PrintWriter clientWriter = null;
@@ -58,7 +59,8 @@ public class TestFrameworkSocket implements AutoCloseable {
public TestFrameworkSocket() {
try {
- serverSocket = new ServerSocket(0);
+ serverSocket = new ServerSocket();
+ serverSocket.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
} catch (IOException e) {
throw new TestFrameworkException("Failed to create TestFramework server socket", e);
}
@@ -132,7 +134,7 @@ public class TestFrameworkSocket implements AutoCloseable {
try {
// Keep the client socket open until the test VM terminates (calls closeClientSocket before exiting main()).
if (clientSocket == null) {
- clientSocket = new Socket(HOSTNAME, SERVER_PORT);
+ clientSocket = new Socket(InetAddress.getLoopbackAddress(), SERVER_PORT);
clientWriter = new PrintWriter(clientSocket.getOutputStream(), true);
}
if (stdout) {