aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorOleksandr Moliavko <o.moliavko@samsung.com>2019-08-01 14:02:18 +0300
committerOleksandr Moliavko <o.moliavko@samsung.com>2019-08-01 14:02:18 +0300
commit8186ec2416f3a41cd0d4dc91e357539522d2dd9b (patch)
tree82c898a94504440ab5956e732b1389e5e0c29695 /bpmn
parent0bf3a7f44ca4f0101c972029c7254606793627ad (diff)
Fixed potential crashes due to null object
dereference attempts in exception handlers Issue-ID: SO-1841 Signed-off-by: Oleksandr Moliavko <o.moliavko@samsung.com> Change-Id: I9882171b47b6442fa8ca12110d8ef23fc975347b
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java31
1 files changed, 23 insertions, 8 deletions
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 2e66493a25..1442099286 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 @@ public class BaseTask implements JavaDelegate {
}
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 @@ public class BaseTask implements JavaDelegate {
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 @@ public class BaseTask implements JavaDelegate {
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 @@ public class BaseTask implements JavaDelegate {
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 @@ public class BaseTask implements JavaDelegate {
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());
+ }
}
}
}