RANGER-4125: Simplifies the dependency of `gethostname4j` for the ranger client
Currently, ranger-plugin-commons module relies on gethostname4j, jna and jna-platform to get the native hostname, which is for AuthzAuditEvent only.
gethostname4j, jna and jna-platform is too onerous, it doesn't seem worthwhile to maintain the three jars to get the hostname, and gethostname4j, jna and jna-platform relies on the native lib, which prevents users from doing shade.
Could you please take a look if you find a moments, thanks @kumaab
@mneethiraj @kumaab could you guys give some background on why should use gethostname4j?
Based on https://stackoverflow.com/questions/7348711/recommended-way-to-get-hostname-in-java
I suppose it could be replaced with org.apache.commons.lang3.SystemUtils#getHostName
/**
* Gets the host name from an environment variable
* (COMPUTERNAME on Windows, HOSTNAME elsewhere).
*
* <p>
* If you want to know what the network stack says is the host name, you should use {@code InetAddress.getLocalHost().getHostName()}.
* </p>
*
* @return the host name. Will be {@code null} if the environment variable is not defined.
* @since 3.6
*/
public static String getHostName() {
return IS_OS_WINDOWS ? System.getenv("COMPUTERNAME") : System.getenv("HOSTNAME");
}