Skip to content

Commit 31572d6

Browse files
author
Steve Vaughan Jr
committed
Avoid SpotBugs warning
SpotBugs is concerned that getCanonicalHostName() may return null, although the JavaDocs indicate that it will return the IP address as a String if unable to determine the FQDN. The only circumstance I can imagine where it would return null is if the IP address is null, which would mean a reverse lookup wouldn't work either.
1 parent e88831b commit 31572d6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNSDomainNameResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public String getHostnameByIP(InetAddress address) {
5050
}
5151
// Protect against the Java behaviour of returning the IP address as a string from a cache
5252
// instead of performing a reverse lookup.
53-
if (host.equals(address.getHostAddress())) {
53+
if (host != null && host.equals(address.getHostAddress())) {
5454
LOG.debug("IP address returned for FQDN detected: {}", address.getHostAddress());
5555
try {
5656
return DNS.reverseDns(address, null);

0 commit comments

Comments
 (0)