Merge "Fixed potential crashes due to null object dereference attempts in exception handlers"
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java
index 2e66493..1442099 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java
@@ -86,8 +86,13 @@
             }
             return variable;
         } else {
-            throw new BadInjectedFieldException(fieldName, getTaskName(),
-                    "expected a variable name string" + ", got object of type " + o.getClass().getName());
+            if (o != null) {
+                throw new BadInjectedFieldException(fieldName, getTaskName(),
+                        "expected a variable name string, got object of type " + o.getClass().getName());
+            } else {
+                throw new BadInjectedFieldException(fieldName, getTaskName(),
+                        "expected a variable name string, got null object");
+            }
         }
     }
 
@@ -114,7 +119,7 @@
             return null;
         } else {
             throw new BadInjectedFieldException(fieldName, getTaskName(),
-                    "expected a variable name string" + ", got object of type " + o.getClass().getName());
+                    "expected a variable name string, got object of type " + o.getClass().getName());
         }
     }
 
@@ -133,9 +138,11 @@
         Object o = getFieldImpl(expression, execution, fieldName, false);
         if (o instanceof String) {
             return (String) o;
-        } else {
+        } else if (o != null) {
             throw new BadInjectedFieldException(fieldName, getTaskName(),
                     "cannot convert '" + o.toString() + "' to Integer");
+        } else {
+            throw new MissingInjectedFieldException(fieldName, getTaskName());
         }
     }
 
@@ -189,8 +196,12 @@
             try {
                 return Integer.parseInt(o.toString());
             } catch (NumberFormatException e) {
-                throw new BadInjectedFieldException(fieldName, getTaskName(),
-                        "cannot convert '" + o.toString() + "' to Integer");
+                if (o != null) {
+                    throw new BadInjectedFieldException(fieldName, getTaskName(),
+                            "cannot convert '" + o.toString() + "' to Integer");
+                } else {
+                    throw new MissingInjectedFieldException(fieldName, getTaskName());
+                }
             }
         }
     }
@@ -289,8 +300,12 @@
             try {
                 return Long.parseLong(o.toString());
             } catch (NumberFormatException e) {
-                throw new BadInjectedFieldException(fieldName, getTaskName(),
-                        "cannot convert '" + o.toString() + "' to Long");
+                if (o != null) {
+                    throw new BadInjectedFieldException(fieldName, getTaskName(),
+                            "cannot convert '" + o.toString() + "' to Long");
+                } else {
+                    throw new MissingInjectedFieldException(fieldName, getTaskName());
+                }
             }
         }
     }