mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use InetAddress.getLoopbackAddress()
This commit is contained in:
@@ -112,6 +112,7 @@ import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -1205,7 +1206,7 @@ public class BuildManager implements Disposable {
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
|
||||
final OSProcessHandler processHandler = new OSProcessHandler(cmdLine) {
|
||||
@Override
|
||||
protected boolean shouldDestroyProcessRecursively() {
|
||||
@@ -1336,7 +1337,7 @@ public class BuildManager implements Disposable {
|
||||
myMessageDispatcher);
|
||||
}
|
||||
});
|
||||
Channel serverChannel = bootstrap.bind(NetUtils.getLoopbackAddress(), 0).syncUninterruptibly().channel();
|
||||
Channel serverChannel = bootstrap.bind(InetAddress.getLoopbackAddress(), 0).syncUninterruptibly().channel();
|
||||
myChannelRegistrar.add(serverChannel);
|
||||
return ((InetSocketAddress)serverChannel.localAddress()).getPort();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,13 +17,13 @@ package com.intellij.execution.runners;
|
||||
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
|
||||
@@ -95,7 +95,7 @@ class ProcessProxyImpl implements ProcessProxy {
|
||||
if (myWriter == null) {
|
||||
try {
|
||||
if (mySocket == null) {
|
||||
mySocket = new Socket(NetUtils.getLoopbackAddress(), myPortNumber);
|
||||
mySocket = new Socket(InetAddress.getLoopbackAddress(), myPortNumber);
|
||||
}
|
||||
myWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(mySocket.getOutputStream())));
|
||||
}
|
||||
|
||||
@@ -33,12 +33,6 @@ public class NetUtils {
|
||||
|
||||
private NetUtils() { }
|
||||
|
||||
/** @deprecated use {@link #canConnectToSocket(String, int)} (to be remove in IDEA 17) */
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean canConnectToSocketOpenedByJavaProcess(String host, int port) {
|
||||
return canConnectToSocket(host, port);
|
||||
}
|
||||
|
||||
public static boolean canConnectToSocket(String host, int port) {
|
||||
if (isLocalhost(host)) {
|
||||
return !canBindToLocalSocket(host, port);
|
||||
@@ -48,6 +42,7 @@ public class NetUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static InetAddress getLoopbackAddress() {
|
||||
return InetAddress.getLoopbackAddress();
|
||||
}
|
||||
@@ -218,6 +213,6 @@ public class NetUtils {
|
||||
}
|
||||
|
||||
public static boolean isSniEnabled() {
|
||||
return SystemInfo.isJavaVersionAtLeast("1.7") && SystemProperties.getBooleanProperty("jsse.enableSNIExtension", true);
|
||||
return SystemProperties.getBooleanProperty("jsse.enableSNIExtension", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.intellij.util.Consumer;
|
||||
import com.intellij.util.NotNullProducer;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
@@ -40,6 +39,7 @@ import org.jetbrains.io.MessageDecoder;
|
||||
import java.io.*;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -189,7 +189,7 @@ public final class SocketLock {
|
||||
log("trying: port=%s", portNumber);
|
||||
args = checkForJetBrainsProtocolCommand(args);
|
||||
try {
|
||||
Socket socket = new Socket(NetUtils.getLoopbackAddress(), portNumber);
|
||||
Socket socket = new Socket(InetAddress.getLoopbackAddress(), portNumber);
|
||||
try {
|
||||
socket.setSoTimeout(1000);
|
||||
|
||||
@@ -249,7 +249,7 @@ public final class SocketLock {
|
||||
|
||||
private static void printPID(int port) {
|
||||
try {
|
||||
Socket socket = new Socket(NetUtils.getLoopbackAddress(), port);
|
||||
Socket socket = new Socket(InetAddress.getLoopbackAddress(), port);
|
||||
socket.setSoTimeout(1000);
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
||||
out.writeUTF(PID_COMMAND);
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package com.intellij.util.io.socketConnection.impl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.io.socketConnection.*;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -72,7 +71,7 @@ public class SocketConnectionImpl<Request extends AbstractRequest, Response exte
|
||||
host = InetAddress.getLocalHost();
|
||||
}
|
||||
catch (UnknownHostException ignored) {
|
||||
host = NetUtils.getLoopbackAddress();
|
||||
host = InetAddress.getLoopbackAddress();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +97,7 @@ public class SocketConnectionImpl<Request extends AbstractRequest, Response exte
|
||||
Exception exception = null;
|
||||
InetAddress host = myHost;
|
||||
if (host == null) {
|
||||
host = NetUtils.getLoopbackAddress();
|
||||
host = InetAddress.getLoopbackAddress();
|
||||
}
|
||||
|
||||
for (int attempt = 0; attempt < MAX_CONNECTION_ATTEMPTS; attempt++) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.NotNullProducer;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
@@ -140,7 +139,7 @@ public class BuiltInServer implements Disposable {
|
||||
boolean tryAnyPort,
|
||||
@NotNull ServerBootstrap bootstrap,
|
||||
@NotNull ChannelRegistrar channelRegistrar) throws Exception {
|
||||
InetAddress address = NetUtils.getLoopbackAddress();
|
||||
InetAddress address = InetAddress.getLoopbackAddress();
|
||||
|
||||
for (int i = 0; i < portsCount; i++) {
|
||||
int port = firstPort + i;
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -30,6 +29,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
@@ -95,7 +95,7 @@ class OutputTabAdapter extends ProcessAdapter {
|
||||
@Nullable
|
||||
private InputStream connect(int port) throws IOException {
|
||||
final long s = System.currentTimeMillis();
|
||||
final InetSocketAddress endpoint = new InetSocketAddress(NetUtils.getLoopbackAddress(), port);
|
||||
final InetSocketAddress endpoint = new InetSocketAddress(InetAddress.getLoopbackAddress(), port);
|
||||
|
||||
myStartedProcess.notifyTextAvailable("Connecting to XSLT runner on " + endpoint + "\n", ProcessOutputTypes.SYSTEM);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user