maedhroz commented on code in PR #1962:
URL: https://github.com/apache/cassandra/pull/1962#discussion_r1040074418


##########
src/java/org/apache/cassandra/config/Config.java:
##########
@@ -1171,8 +1173,9 @@ public static void log(Config config)
             String value;
             try
             {
-                // Field.get() can throw NPE if the value of the field is null
-                value = field.get(config).toString();
+                // don't use exceptions for normal control flow!
+                Object obj = field.get(config);
+                value = obj != null ? obj.toString() : "null";

Review Comment:
   `Field#get()` throws an NPE, supposedly, if `obj` is `null` and we're 
looking at an instance `Field`. The `Config` `obj` passed in here should never 
be `null`, at least as I read it, and we now explicitly check `obj`, so 
removing the `NPE` from the `catch` block should be fine.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to