FULL PRODUCT VERSION:
java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)
OS VERSION:
sw_vers
ProductName: macOS
ProductVersion: 13.3.1
ProductVersionExtra: (a)
BuildVersion: 22E772610a
A DESCRIPTION OF THE PROBLEM :
getCanonicalHostName returns ip address in macOS instead of fully qualified domain name.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Followed these documents to check the macOS machine host name
https://support.apple.com/en-in/guide/mac-help/mchlp2322/mac
https://support.apple.com/en-in/guide/mac-help/mh27452/13.0/mac/13.0
If we verify the macOS machine name it with scutil command we can see the host name.
scutil --get HostName
bishnaya-mac
scutil --get LocalHostName
bishnaya-mac
scutil --get ComputerName
bishnaya-mac
If we run the below code it returns ip address
============code==================
import java.net.InetAddress;
import java.net.UnknownHostException;
public class MachineName {
public static void main(String arg[]) throws UnknownHostException {
String canHostName = InetAddress.getLocalHost().getCanonicalHostName();
System.out.println("Canonical Host Name : "+canHostName);
}
}
===========================================
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED - Canonical Host Name : bishnaya-mac
ACTUAL - Canonical Host Name : ip_address_of_machine
java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)
OS VERSION:
sw_vers
ProductName: macOS
ProductVersion: 13.3.1
ProductVersionExtra: (a)
BuildVersion: 22E772610a
A DESCRIPTION OF THE PROBLEM :
getCanonicalHostName returns ip address in macOS instead of fully qualified domain name.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Followed these documents to check the macOS machine host name
https://support.apple.com/en-in/guide/mac-help/mchlp2322/mac
https://support.apple.com/en-in/guide/mac-help/mh27452/13.0/mac/13.0
If we verify the macOS machine name it with scutil command we can see the host name.
scutil --get HostName
bishnaya-mac
scutil --get LocalHostName
bishnaya-mac
scutil --get ComputerName
bishnaya-mac
If we run the below code it returns ip address
============code==================
import java.net.InetAddress;
import java.net.UnknownHostException;
public class MachineName {
public static void main(String arg[]) throws UnknownHostException {
String canHostName = InetAddress.getLocalHost().getCanonicalHostName();
System.out.println("Canonical Host Name : "+canHostName);
}
}
===========================================
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED - Canonical Host Name : bishnaya-mac
ACTUAL - Canonical Host Name : ip_address_of_machine
- csr for
-
JDK-8313677 InetAddress.getCanonicalHostName may return ip address if reverse lookup fails
- Closed
- links to
-
Commit openjdk/jdk/0cb9ab04
-
Review(master) openjdk/jdk/15134