kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaofeng...@apache.org
Subject [32/45] incubator-kylin git commit: minor, fix NPE in CubingJob.formatNotifications()
Date Mon, 26 Oct 2015 09:08:18 GMT
minor, fix NPE in CubingJob.formatNotifications()


Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/1c1a24cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/1c1a24cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/1c1a24cd

Branch: refs/heads/master
Commit: 1c1a24cdd5dba36e27b9419efcc975ab721836cd
Parents: f00c838
Author: Yang Li <liyang@apache.org>
Authored: Wed Oct 7 09:27:43 2015 +0800
Committer: Yang Li <liyang@apache.org>
Committed: Wed Oct 7 09:27:43 2015 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/kylin/common/util/StringUtil.java   | 8 +++++++-
 job/src/main/java/org/apache/kylin/job/cube/CubingJob.java   | 5 +++--
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/1c1a24cd/common/src/main/java/org/apache/kylin/common/util/StringUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/kylin/common/util/StringUtil.java b/common/src/main/java/org/apache/kylin/common/util/StringUtil.java
index e500612..dbf3380 100644
--- a/common/src/main/java/org/apache/kylin/common/util/StringUtil.java
+++ b/common/src/main/java/org/apache/kylin/common/util/StringUtil.java
@@ -21,6 +21,8 @@ package org.apache.kylin.common.util;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.commons.lang.StringUtils;
+
 /**
  * Created with IntelliJ IDEA. User: lukhan Date: 12/2/13 Time: 11:43 AM To
  * change this template use File | Settings | File Templates.
@@ -56,7 +58,11 @@ public class StringUtil {
             }
         }
     }
-
+    
+    public static String noBlank(String str, String dft) {
+        return StringUtils.isBlank(str) ? dft : str;
+    }
+    
     public static String dropSuffix(String str, String suffix) {
         if (str.endsWith(suffix))
             return str.substring(0, str.length() - suffix.length());

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/1c1a24cd/job/src/main/java/org/apache/kylin/job/cube/CubingJob.java
----------------------------------------------------------------------
diff --git a/job/src/main/java/org/apache/kylin/job/cube/CubingJob.java b/job/src/main/java/org/apache/kylin/job/cube/CubingJob.java
index bf491a8..760a6c3 100644
--- a/job/src/main/java/org/apache/kylin/job/cube/CubingJob.java
+++ b/job/src/main/java/org/apache/kylin/job/cube/CubingJob.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
+import org.apache.kylin.common.util.StringUtil;
 import org.apache.kylin.job.common.MapReduceExecutable;
 import org.apache.kylin.job.constant.ExecutableConstants;
 import org.apache.kylin.job.execution.AbstractExecutable;
@@ -91,8 +92,8 @@ public class CubingJob extends DefaultChainedExecutable {
         content = content.replaceAll("\\$\\{duration\\}", getDuration() / 60000 + "mins");
         content = content.replaceAll("\\$\\{mr_waiting\\}", getMapReduceWaitTime() / 60000
+ "mins");
         content = content.replaceAll("\\$\\{last_update_time\\}", new Date(getLastModified()).toString());
-        content = content.replaceAll("\\$\\{submitter\\}", getSubmitter());
-        content = content.replaceAll("\\$\\{error_log\\}", logMsg);
+        content = content.replaceAll("\\$\\{submitter\\}", StringUtil.noBlank(getSubmitter(),
"missing submitter"));
+        content = content.replaceAll("\\$\\{error_log\\}", StringUtil.noBlank(logMsg, "no
error log"));
 
         try {
             InetAddress inetAddress = InetAddress.getLocalHost();


Mime
View raw message