You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2021/11/09 00:01:09 UTC

[atlas] branch branch-2.0 updated: ATLAS-4431: Random NPE when retrieving tasks - #2 - added additional null check

This is an automated email from the ASF dual-hosted git repository.

sarath pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new ee456fe  ATLAS-4431: Random NPE when retrieving tasks - #2 - added additional null check
ee456fe is described below

commit ee456fed753ddc6cdff6cf6dd587a4a764dcb71f
Author: Disha Talreja <di...@cloudera.com>
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 <sa...@apache.org>
    (cherry picked from commit 2be96918c89e54da15ce399f774a1938ab07f3db)
---
 .../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;
     }