Repository: james-project
Updated Branches:
  refs/heads/master 21188d00e -> e7b962af1


JAMES-2250 Delete redundant null checks

The instanceof operator results in true iff the value of the expression
is not null and could be cast to the specified reference type without
raising a ClassCastException.

Also, within checkMessageIdAttribute(), log the type of messageId if it
is not a String.


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

Branch: refs/heads/master
Commit: e7b962af107508b1ee03792d26b557b7e6bcdd0c
Parents: 21188d0
Author: Daniel Trebbien <dtrebb...@gmail.com>
Authored: Thu Oct 26 14:39:20 2017 -0400
Committer: benwa <btell...@linagora.com>
Committed: Thu Dec 7 09:16:14 2017 +0700

----------------------------------------------------------------------
 .../james/jmap/send/PostDequeueDecorator.java   | 21 ++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e7b962af/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/PostDequeueDecorator.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/PostDequeueDecorator.java
 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/PostDequeueDecorator.java
index 1b383e5..20fbdad 100644
--- 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/PostDequeueDecorator.java
+++ 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/PostDequeueDecorator.java
@@ -100,21 +100,22 @@ public class PostDequeueDecorator extends 
MailQueueItemDecorator {
 
     private boolean checkMessageIdAttribute() {
         Serializable messageId = 
getMail().getAttribute(MailMetadata.MAIL_METADATA_MESSAGE_ID_ATTRIBUTE);
-        if (messageId == null || ! (messageId instanceof String)) {
-            return false;
-        }
-        try {
-            messageIdFactory.fromString((String) messageId);
-        } catch (Exception e) {
-            LOG.error("Invalid messageId: " + messageId, e);
-            return false;
+        if (messageId instanceof String) {
+            try {
+                messageIdFactory.fromString((String) messageId);
+                return true;
+            } catch (Exception e) {
+                LOG.error("Invalid messageId: {}", messageId, e);
+            }
+        } else if (messageId != null) {
+            LOG.error("Non-String messageId {} has type {}", messageId, 
messageId.getClass());
         }
-        return true;
+        return false;
     }
 
     private boolean checkUsernameAttribute() {
         Serializable username = 
getMail().getAttribute(MailMetadata.MAIL_METADATA_USERNAME_ATTRIBUTE);
-        return (username != null && username instanceof String);
+        return (username instanceof String);
     }
 
     private void moveFromOutboxToSentWithSeenFlag(MessageId messageId, 
MailboxSession mailboxSession) throws MailQueueException, MailboxException {


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

Reply via email to