zrhoffman commented on a change in pull request #5133:
URL: https://github.com/apache/trafficcontrol/pull/5133#discussion_r503473716



##########
File path: 
traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/edge/Node.java
##########
@@ -200,9 +200,18 @@ public InetAddress getIp6() {
 
        @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
        public void setState(final JsonNode state) {
-               final boolean isAvailable = JsonUtils.optBoolean(state, 
"isAvailable", true);
-               final boolean ipv4Available = JsonUtils.optBoolean(state, 
"ipv4Available", true);
-               final boolean ipv6Available = JsonUtils.optBoolean(state, 
"ipv6Available", true);
+               final boolean ipv4Available;
+               final boolean ipv6Available;
+               if (state == null) {
+                       LOGGER.warn("got null health state for " + fqdn + ". 
Setting it to unavailable!");
+                       isAvailable = false;
+                       ipv4Available = false;
+                       ipv6Available = false;
+               } else {
+                       isAvailable = JsonUtils.optBoolean(state, 
"isAvailable", true);
+                       ipv4Available = JsonUtils.optBoolean(state, 
"ipv4Available", true);
+                       ipv6Available = JsonUtils.optBoolean(state, 
"ipv6Available", true);
+               }

Review comment:
       Previously, if `state` was `null`, `JsonUtils.optBoolean()` would return 
the provided default value. So does this produce a different result than
   
   ```java
   isAvailable = JsonUtils.optBoolean(state, "isAvailable", false);
   ipv4Available = JsonUtils.optBoolean(state, "ipv4Available", false);
   ipv6Available = JsonUtils.optBoolean(state, "ipv6Available", false);
   ```
   ?




----------------------------------------------------------------
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:
[email protected]


Reply via email to