JAMES-2352 Avoid unneeded MailAddress copy This is unecessary since mailet and smtp MailAddress objects had been merged in a single core object.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1b5bfe8e Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1b5bfe8e Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1b5bfe8e Branch: refs/heads/master Commit: 1b5bfe8ebef576221c51a8777db585318ab3a5b1 Parents: d5f5e7f Author: benwa <btell...@linagora.com> Authored: Wed Mar 21 10:41:46 2018 +0700 Committer: benwa <btell...@linagora.com> Committed: Tue Mar 27 15:14:04 2018 +0700 ---------------------------------------------------------------------- .../apache/james/lmtpserver/DataLineLMTPHandler.java | 11 +---------- .../smtpserver/DataLineJamesMessageHookHandler.java | 15 +++------------ 2 files changed, 4 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/1b5bfe8e/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java ---------------------------------------------------------------------- diff --git a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java index 514effd..6081d33 100644 --- a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java +++ b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/DataLineLMTPHandler.java @@ -24,8 +24,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import javax.mail.internet.AddressException; - import org.apache.james.core.MailAddress; import org.apache.james.protocols.api.Response; import org.apache.james.protocols.api.handler.WiringException; @@ -55,16 +53,9 @@ public class DataLineLMTPHandler extends DataLineJamesMessageHookHandler { final ReadOnlyMailEnvelope env = new ReadOnlyMailEnvelope(mail); for (MailAddress recipient : mail.getRecipients()) { - // TODO: the transformation code between MailAddress is purely to compile. No idea if it does what it's supposed - MailAddress recipientAddress; - try { - recipientAddress = new MailAddress(recipient.getLocalPart(), recipient.getDomain()); - } catch (AddressException e) { - throw new RuntimeException(e); - } Response response = null; for (DeliverToRecipientHook handler : handlers) { - response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(handler.deliver(session, recipientAddress, env)); + response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(handler.deliver(session, recipient, env)); if (response != null) { break; } http://git-wip-us.apache.org/repos/asf/james-project/blob/1b5bfe8e/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java ---------------------------------------------------------------------- diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java index 70b3b47..0c625c7 100644 --- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java +++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java @@ -23,12 +23,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import javax.mail.MessagingException; -import javax.mail.internet.AddressException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; @@ -57,6 +55,8 @@ import org.apache.mailet.Mail; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.collect.ImmutableList; + /** * Handles the calling of JamesMessageHooks */ @@ -256,16 +256,7 @@ public class DataLineJamesMessageHookHandler implements DataLineFilter, Extensib @Override public List<MailAddress> getRecipients() { - //TODO: not sure this MailAddress transformation code does the right thing - List<MailAddress> mailAddressList = new ArrayList<>(); - for (MailAddress address : mail.getRecipients()) { - try { - mailAddressList.add(new MailAddress(address.getLocalPart(), address.getDomain())); - } catch (AddressException ex) { - throw new RuntimeException(ex); - } - } - return mailAddressList; + return ImmutableList.copyOf(mail.getRecipients()); } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org