Github user d2r commented on a diff in the pull request:
https://github.com/apache/incubator-storm/pull/120#discussion_r14793687
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -301,15 +332,39 @@ public static ComponentCommon
getComponentCommon(StormTopology topology, String
}
public static Integer getInt(Object o) {
- if(o instanceof Long) {
- return ((Long) o ).intValue();
- } else if (o instanceof Integer) {
- return (Integer) o;
- } else if (o instanceof Short) {
- return ((Short) o).intValue();
- } else {
- throw new IllegalArgumentException("Don't know how to convert
" + o + " + to int");
- }
+ Integer result = getInt(o, null);
+ if (null == result) {
+ throw new IllegalArgumentException("Don't know how to convert null
+ to int");
+ }
+ return result;
+ }
+
+ public static Integer getInt(Object o, Integer defaultValue) {
+ if (null == o) {
+ return defaultValue;
+ }
+
+ if(o instanceof Long) {
+ return ((Long) o ).intValue();
+ } else if (o instanceof Integer) {
+ return (Integer) o;
+ } else if (o instanceof Short) {
+ return ((Short) o).intValue();
+ } else {
+ throw new IllegalArgumentException("Don't know how to convert "
+ o + " + to int");
+ }
+ }
+
+ public static boolean getBoolean(Object o, boolean defaultValue) {
+ if (null == o) {
+ return defaultValue;
+ }
+
+ if(o instanceof Boolean) {
+ return (Boolean) o;
+ } else {
+ throw new IllegalArgumentException("Don't know how to convert "
+ o + " + to boolean");
+ }
}
--- End diff --
getBoolean seems to be an addition unrelated to the changes for this JIRA.
It should be in its own pull request.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---