You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pv...@apache.org on 2020/08/24 14:27:06 UTC
[nifi] branch main updated: NIFI-7758: Avoid calling
InetAddress.getHostName() because doing so results in a reverse DNS Lookup,
which can be expensive
This is an automated email from the ASF dual-hosted git repository.
pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 11a4127 NIFI-7758: Avoid calling InetAddress.getHostName() because doing so results in a reverse DNS Lookup, which can be expensive
11a4127 is described below
commit 11a4127a9f89474a42f182c0b83e365a6b468e71
Author: Mark Payne <ma...@hotmail.com>
AuthorDate: Mon Aug 24 09:11:00 2020 -0400
NIFI-7758: Avoid calling InetAddress.getHostName() because doing so results in a reverse DNS Lookup, which can be expensive
Signed-off-by: Pierre Villard <pi...@gmail.com>
This closes #4487.
---
.../apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java b/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java
index dc36926..6dd167f 100644
--- a/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java
+++ b/nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/remote/io/socket/ssl/SSLSocketChannel.java
@@ -51,7 +51,7 @@ public class SSLSocketChannel implements Closeable {
private static final Logger logger = LoggerFactory.getLogger(SSLSocketChannel.class);
private static final long BUFFER_FULL_EMPTY_WAIT_NANOS = TimeUnit.NANOSECONDS.convert(1, TimeUnit.MILLISECONDS);
- private final String hostname;
+ private final String remoteAddress;
private final int port;
private final SSLEngine engine;
private final SocketAddress socketAddress;
@@ -77,7 +77,7 @@ public class SSLSocketChannel implements Closeable {
final SocketAddress localSocketAddress = new InetSocketAddress(localAddress, 0);
this.channel.bind(localSocketAddress);
}
- this.hostname = hostname;
+ this.remoteAddress = hostname;
this.port = port;
this.engine = sslContext.createSSLEngine();
this.engine.setUseClientMode(client);
@@ -97,7 +97,7 @@ public class SSLSocketChannel implements Closeable {
this.socketAddress = socketChannel.getRemoteAddress();
final Socket socket = socketChannel.socket();
- this.hostname = socket.getInetAddress().getHostName();
+ this.remoteAddress = socket.getInetAddress().toString();
this.port = socket.getPort();
this.engine = sslContext.createSSLEngine();
@@ -118,7 +118,7 @@ public class SSLSocketChannel implements Closeable {
this.socketAddress = socketChannel.getRemoteAddress();
final Socket socket = socketChannel.socket();
- this.hostname = socket.getInetAddress().getHostName();
+ this.remoteAddress = socket.getInetAddress().toString();
this.port = socket.getPort();
// don't set useClientMode or needClientAuth, use the engine as is and let the caller configure it
@@ -149,7 +149,7 @@ public class SSLSocketChannel implements Closeable {
throw new TransmissionDisabledException();
}
if (System.currentTimeMillis() > startTime + timeoutMillis) {
- throw new SocketTimeoutException("Timed out connecting to " + hostname + ":" + port);
+ throw new SocketTimeoutException("Timed out connecting to " + remoteAddress + ":" + port);
}
try {
@@ -311,7 +311,7 @@ public class SSLSocketChannel implements Closeable {
long sleepNanos = 1L;
if (readCount == 0) {
if (System.currentTimeMillis() > startTime + timeoutMillis) {
- throw new SocketTimeoutException("Timed out reading from socket connected to " + hostname + ":" + port);
+ throw new SocketTimeoutException("Timed out reading from socket connected to " + remoteAddress + ":" + port);
}
try {
TimeUnit.NANOSECONDS.sleep(sleepNanos);
@@ -370,7 +370,7 @@ public class SSLSocketChannel implements Closeable {
lastByteWrittenTime = now;
} else {
if (now > lastByteWrittenTime + timeoutMillis) {
- throw new SocketTimeoutException("Timed out writing to socket connected to " + hostname + ":" + port);
+ throw new SocketTimeoutException("Timed out writing to socket connected to " + remoteAddress + ":" + port);
}
try {
TimeUnit.NANOSECONDS.sleep(sleepNanos);