Remove forbidden suppressions for InetSocketAddress
This commit is contained in:
parent
7cbb955d19
commit
a0c69fe7f9
|
@ -105,6 +105,7 @@ import org.elasticsearch.watcher.ResourceWatcherService;
|
|||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.CopyOption;
|
||||
|
@ -453,13 +454,12 @@ public class Node implements Releasable {
|
|||
Path tmpPortsFile = environment.logsFile().resolve(type + ".ports.tmp");
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(tmpPortsFile, Charset.forName("UTF-8"))) {
|
||||
for (TransportAddress address : boundAddress.boundAddresses()) {
|
||||
InetSocketAddress socketAddress = buildAddress(address.getAddress(), address.getPort());
|
||||
if (socketAddress.getAddress() instanceof Inet6Address &&
|
||||
socketAddress.getAddress().isLinkLocalAddress()) {
|
||||
InetAddress inetAddress = InetAddress.getByName(address.getAddress());
|
||||
if (inetAddress instanceof Inet6Address && inetAddress.isLinkLocalAddress()) {
|
||||
// no link local, just causes problems
|
||||
continue;
|
||||
}
|
||||
writer.write(NetworkAddress.formatAddress(socketAddress) + "\n");
|
||||
writer.write(NetworkAddress.formatAddress(new InetSocketAddress(inetAddress, address.getPort())) + "\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to write ports file", e);
|
||||
|
@ -471,9 +471,4 @@ public class Node implements Releasable {
|
|||
throw new RuntimeException("Failed to rename ports file", e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressForbidden(reason = "Need to specify address and port")
|
||||
private static InetSocketAddress buildAddress(String address, int port) {
|
||||
return new InetSocketAddress(address, port);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,14 +107,14 @@ public abstract class ESSmokeClientTestCase extends LuceneTestCase {
|
|||
return client;
|
||||
}
|
||||
|
||||
@SuppressForbidden(reason = "Must use port when creating address")
|
||||
private static Client startClient() throws IOException {
|
||||
String[] stringAddresses = clusterAddresses.split(",");
|
||||
TransportAddress[] transportAddresses = new TransportAddress[stringAddresses.length];
|
||||
int i = 0;
|
||||
for (String stringAddress : stringAddresses) {
|
||||
URL url = new URL("http://" + stringAddress);
|
||||
transportAddresses[i++] = new InetSocketTransportAddress(new InetSocketAddress(url.getHost(), url.getPort()));
|
||||
InetAddress inetAddress = InetAddress.getByName(url.getHost());
|
||||
transportAddresses[i++] = new InetSocketTransportAddress(new InetSocketAddress(inetAddress, url.getPort()));
|
||||
}
|
||||
return startClient(createTempDir(), transportAddresses);
|
||||
}
|
||||
|
|
|
@ -1730,14 +1730,14 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
return Settings.EMPTY;
|
||||
}
|
||||
|
||||
@SuppressForbidden(reason = "Must use port when creating address")
|
||||
private ExternalTestCluster buildExternalCluster(String clusterAddresses) throws IOException {
|
||||
String[] stringAddresses = clusterAddresses.split(",");
|
||||
TransportAddress[] transportAddresses = new TransportAddress[stringAddresses.length];
|
||||
int i = 0;
|
||||
for (String stringAddress : stringAddresses) {
|
||||
URL url = new URL("http://" + stringAddress);
|
||||
transportAddresses[i++] = new InetSocketTransportAddress(new InetSocketAddress(url.getHost(), url.getPort()));
|
||||
InetAddress inetAddress = InetAddress.getByName(url.getHost());
|
||||
transportAddresses[i++] = new InetSocketTransportAddress(new InetSocketAddress(inetAddress, url.getPort()));
|
||||
}
|
||||
return new ExternalTestCluster(createTempDir(), externalClusterClientSettings(), transportClientPlugins(), transportAddresses);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue