james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [13/17] james-project git commit: JAMES-2578 Require JSON object node never to be null
Date Thu, 01 Nov 2018 04:07:48 GMT
JAMES-2578 Require JSON object node never to be null


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1ccae901
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1ccae901
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1ccae901

Branch: refs/heads/master
Commit: 1ccae9018a115ccec46a3dc0d2d000450d7ef6c6
Parents: 77f4ecb
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Oct 30 14:25:58 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Thu Nov 1 11:03:38 2018 +0700

----------------------------------------------------------------------
 .../api/src/main/java/org/apache/mailet/AttributeValue.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1ccae901/mailet/api/src/main/java/org/apache/mailet/AttributeValue.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/main/java/org/apache/mailet/AttributeValue.java b/mailet/api/src/main/java/org/apache/mailet/AttributeValue.java
index 4ae6952..638dd34 100644
--- a/mailet/api/src/main/java/org/apache/mailet/AttributeValue.java
+++ b/mailet/api/src/main/java/org/apache/mailet/AttributeValue.java
@@ -176,9 +176,12 @@ public class AttributeValue<T> {
     }
 
     public static Optional<?> deserialize(ObjectNode fields) {
-        return Optional.ofNullable(fields.get("serializer"))
-                .flatMap(serializer ->  Optional.ofNullable(fields.get("value"))
-                        .flatMap(value -> findSerializerAndDeserialize(serializer, value)));
+        Preconditions.checkNotNull(fields);
+        Optional<JsonNode> maybeSerializer = Optional.ofNullable(fields.get("serializer"));
+        Optional<JsonNode> maybeValue = Optional.ofNullable(fields.get("value"));
+
+        return maybeSerializer.flatMap(serializer -> maybeValue
+            .flatMap(value -> findSerializerAndDeserialize(serializer, value)));
     }
 
     public static Optional<?> findSerializerAndDeserialize(JsonNode serializer, JsonNode
value) {


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message