-
Notifications
You must be signed in to change notification settings - Fork 594
Add null check when heron reads the config file #1682
Conversation
origin 1861 link |
@@ -66,7 +66,7 @@ public void dump(TopologyAPI.Component.Builder bldr) { | |||
for (Map.Entry<String, Object> entry : componentConfiguration.entrySet()) { | |||
TopologyAPI.Config.KeyValue.Builder kvBldr = TopologyAPI.Config.KeyValue.newBuilder(); | |||
kvBldr.setKey(entry.getKey()); | |||
kvBldr.setValue(entry.getValue().toString()); | |||
kvBldr.setValue(entry.getValue() == null ? "null" : entry.getValue().toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put null in there instead of "null".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
👍 |
1 similar comment
👍 |
Did you test it locally with null config-value? @huijunw |
updated. tested. For the null value in the map, there are 4 options:
Thanks for @maosongfu suggestion. |
👍 |
@@ -64,6 +66,10 @@ public void dump(TopologyAPI.Component.Builder bldr) { | |||
|
|||
TopologyAPI.Config.Builder cBldr = TopologyAPI.Config.newBuilder(); | |||
for (Map.Entry<String, Object> entry : componentConfiguration.entrySet()) { | |||
if (entry.getValue() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check entry.getKey() too since the key can also be null.
https://docs.oracle.com/javase/7/docs/api/java/util/Map.html#put(K,%20V)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Looks good to me. 👍 |
Add null check when heron reads the config file
add null check when Heron reads the config file. resolves #1681