You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/07/03 08:35:19 UTC

[GitHub] [cassandra] snazy commented on a change in pull request #652: Cassandra 15901

snazy commented on a change in pull request #652:
URL: https://github.com/apache/cassandra/pull/652#discussion_r449453360



##########
File path: conf/cassandra.yaml
##########
@@ -630,7 +630,8 @@ ssl_storage_port: 7001
 # Leaving it blank leaves it up to InetAddress.getLocalHost(). This
 # will always do the Right Thing _if_ the node is properly configured
 # (hostname, name resolution, etc), and the Right Thing is to use the
-# address associated with the hostname (it might not be).
+# address associated with the hostname (it might not be). If unresolvable
+# it will get InetAddress.getLoopbackAddress()

Review comment:
       ```suggestion
   # it will fall back to InetAddress.getLoopbackAddress(), which is wrong for production systems.
   ```

##########
File path: src/java/org/apache/cassandra/utils/FBUtilities.java
##########
@@ -130,16 +130,24 @@ public static MessageDigest newMessageDigest(String algorithm)
     public static InetAddress getJustLocalAddress()
     {
         if (localInetAddress == null)
-            try
-            {
-                localInetAddress = DatabaseDescriptor.getListenAddress() == null
-                                    ? InetAddress.getLocalHost()
-                                    : DatabaseDescriptor.getListenAddress();
-            }
-            catch (UnknownHostException e)
+        {
+            if (DatabaseDescriptor.getListenAddress() == null)
             {
-                throw new RuntimeException(e);
+                try
+                {
+                    localInetAddress = InetAddress.getLocalHost();
+                }
+                catch(UnknownHostException e)
+                {
+                    logger.info("InetAddress.getLocalHost() could not resolve, please check your node's config. Falling back to {}",
+                                InetAddress.getLoopbackAddress());

Review comment:
       ```suggestion
                                  e, InetAddress.getLoopbackAddress());
   ```

##########
File path: src/java/org/apache/cassandra/utils/FBUtilities.java
##########
@@ -130,16 +130,24 @@ public static MessageDigest newMessageDigest(String algorithm)
     public static InetAddress getJustLocalAddress()
     {
         if (localInetAddress == null)
-            try
-            {
-                localInetAddress = DatabaseDescriptor.getListenAddress() == null
-                                    ? InetAddress.getLocalHost()
-                                    : DatabaseDescriptor.getListenAddress();
-            }
-            catch (UnknownHostException e)
+        {
+            if (DatabaseDescriptor.getListenAddress() == null)
             {
-                throw new RuntimeException(e);
+                try
+                {
+                    localInetAddress = InetAddress.getLocalHost();
+                }
+                catch(UnknownHostException e)
+                {
+                    logger.info("InetAddress.getLocalHost() could not resolve, please check your node's config. Falling back to {}",

Review comment:
       ```suggestion
                       logger.info("InetAddress.getLocalHost() could not resolve the address for the hostname ({}), please check your node's config and set the listen_address in cassandra.yaml. Falling back to {}",
   ```

##########
File path: src/java/org/apache/cassandra/utils/FBUtilities.java
##########
@@ -130,16 +130,24 @@ public static MessageDigest newMessageDigest(String algorithm)
     public static InetAddress getJustLocalAddress()
     {
         if (localInetAddress == null)
-            try
-            {
-                localInetAddress = DatabaseDescriptor.getListenAddress() == null
-                                    ? InetAddress.getLocalHost()
-                                    : DatabaseDescriptor.getListenAddress();
-            }
-            catch (UnknownHostException e)
+        {
+            if (DatabaseDescriptor.getListenAddress() == null)
             {
-                throw new RuntimeException(e);
+                try
+                {
+                    localInetAddress = InetAddress.getLocalHost();

Review comment:
       ```suggestion
                       localInetAddress = InetAddress.getLocalHost();
                       logger.info("InetAddress.getLocalHost() was used to resolve listen_address to {}, this can cause issues. Please check your node's config and set the listen_address in cassandra.yaml.", localInetAddress);
   ```
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org