james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [03/17] james-project git commit: JAMES-2557 RCPT SMTP hooks API should explicitly handle optional sender
Date Thu, 01 Nov 2018 04:07:38 GMT
JAMES-2557 RCPT SMTP hooks API should explicitly handle optional sender

Note that thanks to interface defaults, API compatibility is not broken


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

Branch: refs/heads/master
Commit: 585c1729536e900dff5fe82745199ab1a2713d85
Parents: 93be34c
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Oct 30 10:59:08 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Thu Nov 1 10:56:32 2018 +0700

----------------------------------------------------------------------
 .../james/protocols/smtp/hook/RcptHook.java       | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/585c1729/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
index 0c09663..49d0efa 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/hook/RcptHook.java
@@ -19,6 +19,7 @@
 package org.apache.james.protocols.smtp.hook;
 
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.MaybeSender;
 import org.apache.james.protocols.smtp.SMTPSession;
 
 /**
@@ -28,12 +29,27 @@ public interface RcptHook extends Hook {
     
     /**
      * Return the HookResult after run the hook
+     *
+     * @deprecated Use {@link #doRcpt(SMTPSession, MaybeSender, MailAddress)} instead
      * 
      * @param session the SMTPSession
      * @param sender the sender MailAddress
      * @param rcpt the recipient MailAddress
      * @return HookResult
      */
-    HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt);
+    @Deprecated
+    default HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt)
{
+        return doRcpt(session, MaybeSender.of(sender), rcpt);
+    }
+
+    /**
+     * Return the HookResult after run the hook
+     *
+     * this strongly typed version smoothly handle null sender and should be prefered.
+     */
+    @SuppressWarnings("deprecated")
+    default HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt)
{
+        return doRcpt(session, sender.asOptional().orElse(null), rcpt);
+    }
 
 }


---------------------------------------------------------------------
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