Skip to content

Commit f68a4b9

Browse files
committed
8327105: compiler.compilercontrol.share.scenario.Executor should listen on loopback address only
Reviewed-by: chagedorn, kvn
1 parent a9c17a2 commit f68a4b9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

test/hotspot/jtreg/compiler/compilercontrol/share/actions/BaseAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -87,7 +87,7 @@ protected void communicate(String[] args) {
8787
System.out.println("INFO: Client connection port = " + port);
8888
List<String> lines;
8989
try (
90-
Socket socket = new Socket(InetAddress.getLocalHost(), port);
90+
Socket socket = new Socket(InetAddress.getLoopbackAddress(), port);
9191
BufferedReader in = new BufferedReader(
9292
new InputStreamReader(socket.getInputStream()));
9393
PrintWriter out = new PrintWriter(

test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Executor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,8 @@
3636
import java.io.InputStreamReader;
3737
import java.io.PrintWriter;
3838
import java.lang.reflect.Executable;
39+
import java.net.InetAddress;
40+
import java.net.InetSocketAddress;
3941
import java.net.ServerSocket;
4042
import java.net.Socket;
4143
import java.util.ArrayList;
@@ -80,8 +82,9 @@ public List<OutputAnalyzer> execute() {
8082
// Add class name that would be executed in a separate VM
8183
vmOptions.add(execClass);
8284
OutputAnalyzer output;
83-
try (ServerSocket serverSocket = new ServerSocket(0)) {
85+
try (ServerSocket serverSocket = new ServerSocket()) {
8486
{
87+
serverSocket.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
8588
// Get port test VM will connect to
8689
int port = serverSocket.getLocalPort();
8790
if (port == -1) {

0 commit comments

Comments
 (0)