This is an automated email from the ASF dual-hosted git repository.
sarath pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new 2be9691 ATLAS-4431: Random NPE when retrieving tasks - #2 - added
additional null check
2be9691 is described below
commit 2be96918c89e54da15ce399f774a1938ab07f3db
Author: Disha Talreja <[email protected]>
AuthorDate: Mon Nov 8 18:47:42 2021 -0500
ATLAS-4431: Random NPE when retrieving tasks - #2 - added additional null
check
Signed-off-by: Sarath Subramanian <[email protected]>
---
.../java/org/apache/atlas/tasks/TaskRegistry.java | 38 ++++++++++++++++++----
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/repository/src/main/java/org/apache/atlas/tasks/TaskRegistry.java
b/repository/src/main/java/org/apache/atlas/tasks/TaskRegistry.java
index 32e0ad9..6f770ed 100644
--- a/repository/src/main/java/org/apache/atlas/tasks/TaskRegistry.java
+++ b/repository/src/main/java/org/apache/atlas/tasks/TaskRegistry.java
@@ -181,10 +181,25 @@ public class TaskRegistry {
private AtlasTask toAtlasTask(AtlasVertex v) {
AtlasTask ret = new AtlasTask();
- ret.setGuid(v.getProperty(Constants.TASK_GUID, String.class));
- ret.setType(v.getProperty(Constants.TASK_TYPE, String.class));
- ret.setStatus(v.getProperty(Constants.TASK_STATUS, String.class));
- ret.setCreatedBy(v.getProperty(Constants.TASK_CREATED_BY,
String.class));
+ String guid = v.getProperty(Constants.TASK_GUID, String.class);
+ if (guid != null) {
+ ret.setGuid(guid);
+ }
+
+ String type = v.getProperty(Constants.TASK_TYPE, String.class);
+ if (type != null) {
+ ret.setType(type);
+ }
+
+ String status = v.getProperty(Constants.TASK_STATUS, String.class);
+ if (status != null) {
+ ret.setStatus(status);
+ }
+
+ String createdBy = v.getProperty(Constants.TASK_CREATED_BY,
String.class);
+ if (createdBy != null) {
+ ret.setCreatedBy(createdBy);
+ }
Long createdTime = v.getProperty(Constants.TASK_CREATED_TIME,
Long.class);
if (createdTime != null) {
@@ -207,10 +222,19 @@ public class TaskRegistry {
}
String parametersJson = v.getProperty(Constants.TASK_PARAMETERS,
String.class);
- ret.setParameters(AtlasType.fromJson(parametersJson, Map.class));
+ if (parametersJson != null) {
+ ret.setParameters(AtlasType.fromJson(parametersJson, Map.class));
+ }
- ret.setAttemptCount(v.getProperty(Constants.TASK_ATTEMPT_COUNT,
Integer.class));
- ret.setErrorMessage(v.getProperty(Constants.TASK_ERROR_MESSAGE,
String.class));
+ Integer attemptCount = v.getProperty(Constants.TASK_ATTEMPT_COUNT,
Integer.class);
+ if (attemptCount != null) {
+ ret.setAttemptCount(attemptCount);
+ }
+
+ String errorMessage = v.getProperty(Constants.TASK_ERROR_MESSAGE,
String.class);
+ if (errorMessage != null) {
+ ret.setErrorMessage(errorMessage);
+ }
return ret;
}