8224761: Replace wildcard address with loopback or local host in tests - part 12

Fixes a batch of intermittent failures.

Reviewed-by: chegar, vtewari
This commit is contained in:
Daniel Fuchs 2019-05-27 19:24:42 +01:00
parent 625020c0fd
commit 5461726dcc
10 changed files with 124 additions and 56 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, 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
@ -41,6 +41,7 @@ import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.DatagramSocketImpl;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MulticastSocket;
import java.net.UnknownHostException;
import java.nio.file.Files;
@ -73,7 +74,9 @@ public class UnreferencedMulticastSockets {
MulticastSocket ss;
Server() throws IOException {
ss = new MulticastSocket(0);
InetSocketAddress serverAddress =
new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
ss = new MulticastSocket(serverAddress);
System.out.printf(" DatagramServer addr: %s: %d%n",
this.getHost(), this.getPort());
pendingSockets.add(new NamedWeak(ss, pendingQueue, "serverMulticastSocket"));
@ -81,7 +84,7 @@ public class UnreferencedMulticastSockets {
}
InetAddress getHost() throws UnknownHostException {
InetAddress localhost = InetAddress.getByName("localhost"); //.getLocalHost();
InetAddress localhost = InetAddress.getLoopbackAddress();
return localhost;
}