You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by vi...@apache.org on 2020/10/12 00:55:49 UTC

[hudi] branch master updated: [MINOR] NPE Optimization for Option (#2158)

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

vinoth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 032bc3b  [MINOR] NPE Optimization for Option (#2158)
032bc3b is described below

commit 032bc3b08fe61ff23c8a1002d78a8197893d4f89
Author: dugenkui <du...@meituan.com>
AuthorDate: Mon Oct 12 08:55:41 2020 +0800

    [MINOR] NPE Optimization for Option (#2158)
---
 hudi-common/src/main/java/org/apache/hudi/common/util/Option.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hudi-common/src/main/java/org/apache/hudi/common/util/Option.java b/hudi-common/src/main/java/org/apache/hudi/common/util/Option.java
index a67b6ab..42d6057 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/util/Option.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/util/Option.java
@@ -98,6 +98,9 @@ public final class Option<T> implements Serializable {
   }
 
   public <U> Option<U> map(Function<? super T, ? extends U> mapper) {
+    if (null == mapper) {
+      throw new NullPointerException("mapper should not be null");
+    }
     if (!isPresent()) {
       return empty();
     } else {
@@ -140,6 +143,8 @@ public final class Option<T> implements Serializable {
 
   @Override
   public String toString() {
-    return "Option{val=" + val + '}';
+    return val != null
+            ? "Option{val=" + val + "}"
+            : "Optional.empty";
   }
 }