Add null protection in config translation code (#2597)
This change contains only null pointer checks. check job hasn't finished yet but it has been running for awhile so compiling should be successful now.
diff --git a/storm-compatibility/src/java/backtype/storm/utils/ConfigUtils.java b/storm-compatibility/src/java/backtype/storm/utils/ConfigUtils.java
index 18e25de..965e56b 100644
--- a/storm-compatibility/src/java/backtype/storm/utils/ConfigUtils.java
+++ b/storm-compatibility/src/java/backtype/storm/utils/ConfigUtils.java
@@ -38,7 +38,12 @@
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public static Config translateConfig(Map stormConfig) {
- Config heronConfig = new Config((Map<String, Object>) stormConfig);
+ Config heronConfig;
+ if (stormConfig != null) {
+ heronConfig = new Config((Map<String, Object>) stormConfig);
+ } else {
+ heronConfig = new Config();
+ }
// Look at serialization stuff first
doSerializationTranslation(heronConfig);
@@ -60,7 +65,12 @@
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public static Config translateComponentConfig(Map stormConfig) {
- Config heronConfig = new Config((Map<String, Object>) stormConfig);
+ Config heronConfig;
+ if (stormConfig != null) {
+ heronConfig = new Config((Map<String, Object>) stormConfig);
+ } else {
+ heronConfig = new Config();
+ }
doStormTranslation(heronConfig);
diff --git a/storm-compatibility/src/java/org/apache/storm/utils/ConfigUtils.java b/storm-compatibility/src/java/org/apache/storm/utils/ConfigUtils.java
index d7b23a2..614d43f 100644
--- a/storm-compatibility/src/java/org/apache/storm/utils/ConfigUtils.java
+++ b/storm-compatibility/src/java/org/apache/storm/utils/ConfigUtils.java
@@ -38,7 +38,13 @@
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public static Config translateConfig(Map stormConfig) {
- Config heronConfig = new Config((Map<String, Object>) stormConfig);
+ Config heronConfig;
+ if (stormConfig != null) {
+ heronConfig = new Config((Map<String, Object>) stormConfig);
+ } else {
+ heronConfig = new Config();
+ }
+
// Look at serialization stuff first
doSerializationTranslation(heronConfig);
@@ -59,7 +65,12 @@
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public static Config translateComponentConfig(Map stormConfig) {
- Config heronConfig = new Config((Map<String, Object>) stormConfig);
+ Config heronConfig;
+ if (stormConfig != null) {
+ heronConfig = new Config((Map<String, Object>) stormConfig);
+ } else {
+ heronConfig = new Config();
+ }
doStormTranslation(heronConfig);