Skip to content

Commit bbc006f

Browse files
committed
8330278: Have SSLSocketTemplate.doClientSide use loopback address
Backport-of: 0eff492e4107abc5624f0c3445877bf38629a980
1 parent b4ab5de commit bbc006f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 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
@@ -273,7 +273,7 @@ protected void doClientSide() throws Exception {
273273
configureClientSocket(sslSocket);
274274
InetAddress serverAddress = this.serverAddress;
275275
InetSocketAddress connectAddress = serverAddress == null
276-
? new InetSocketAddress("localhost", serverPort)
276+
? new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort)
277277
: new InetSocketAddress(serverAddress, serverPort);
278278
sslSocket.connect(connectAddress, 15000);
279279
} catch (IOException ioe) {

test/jdk/javax/net/ssl/templates/TLSBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.io.InputStreamReader;
3232
import java.io.OutputStreamWriter;
3333
import java.io.PrintWriter;
34+
import java.net.InetAddress;
3435
import java.net.InetSocketAddress;
3536
import java.util.Arrays;
3637
import java.util.concurrent.ConcurrentHashMap;
@@ -222,7 +223,7 @@ public SSLSocket connect() {
222223
try {
223224
sslContext = SSLContext.getDefault();
224225
sock = (SSLSocket)sslContext.getSocketFactory().createSocket();
225-
sock.connect(new InetSocketAddress("localhost", serverPort));
226+
sock.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort));
226227
System.err.println("Client connected using port " +
227228
sock.getLocalPort());
228229
name = "client(" + sock.toString() + ")";

0 commit comments

Comments
 (0)