mneethiraj commented on code in PR #911:
URL: https://github.com/apache/ranger/pull/911#discussion_r3062076618
##########
agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTUtils.java:
##########
@@ -143,12 +142,32 @@ public String getAppIdFromPluginId(String pluginId) {
return ret;
}
- static {
+ private static String getHostname() {
+ String hostname = null;
+
try {
- hostname = Hostname.getHostname();
- } catch (Exception e) {
- LOG.error("ERROR: Unable to find hostname for the agent ", e);
- hostname = "unknownHost";
+ hostname = System.getenv("HOSTNAME");
+ } catch (SecurityException excp) {
+ LOG.error("Error in getting environment HOSTNAME", excp);
}
+
+ if (StringUtils.isBlank(hostname)) {
+ try {
+ hostname = System.getenv("COMPUTERNAME");
+ } catch (SecurityException excp) {
+ LOG.error("Error in getting environment COMPUTERNAME", excp);
+ }
+
+ if (StringUtils.isBlank(hostname)) {
+ try {
+ hostname = InetAddress.getLocalHost().getHostName();
+ } catch (Exception e) {
+ LOG.error("ERROR: Unable to find hostname for the agent ",
e);
+ hostname = "unknownHost";
Review Comment:
Good suggestion. Thanks @vyommani.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]