JAMES-2456 Remove no more needed calls to MailAddress::isNullSender Code working with optional directly take care of this.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3ae94d03 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3ae94d03 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3ae94d03 Branch: refs/heads/master Commit: 3ae94d0337cc99f66f41e3969a2b1b85ee110501 Parents: cc79534 Author: Benoit Tellier <[email protected]> Authored: Wed Oct 24 11:07:34 2018 +0700 Committer: Benoit Tellier <[email protected]> Committed: Tue Dec 11 14:00:07 2018 +0700 ---------------------------------------------------------------------- .../mailets/redirect/MailModifier.java | 29 +++++++++++--------- .../transport/util/SpecialAddressesUtils.java | 4 --- 2 files changed, 16 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/3ae94d03/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java index 2ffc92b..cdad611 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java @@ -37,6 +37,7 @@ import org.apache.mailet.base.RFC2822Headers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.fge.lambdas.Throwing; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -111,7 +112,6 @@ public class MailModifier { if (!recipients.isEmpty()) { mail.setRecipients(recipients .stream() - .filter(address -> !address.isNullSender()) .collect(ImmutableList.toImmutableList())); if (mailet.getInitParameters().isDebug()) { if (LOGGER.isDebugEnabled()) { @@ -144,18 +144,21 @@ public class MailModifier { * the "Reply-To:" header. If the requested value is null does nothing.</p> */ public void setReplyTo(Optional<MailAddress> optionalReplyTo) throws MessagingException { - if (optionalReplyTo.isPresent()) { - MailAddress replyTo = optionalReplyTo.get(); - if (replyTo.isNullSender() || replyTo.equals(SpecialAddress.NULL)) { - mail.getMessage().setReplyTo(null); - if (mailet.getInitParameters().isDebug()) { - LOGGER.debug("replyTo set to: null"); - } - } else { - mail.getMessage().setReplyTo(new InternetAddress[] { replyTo.toInternetAddress() }); - if (mailet.getInitParameters().isDebug()) { - LOGGER.debug("replyTo set to: {}", replyTo); - } + optionalReplyTo.ifPresent(Throwing + .consumer((MailAddress address) -> setReplyTo(address)) + .sneakyThrow()); + } + + private void setReplyTo(MailAddress replyTo) throws MessagingException { + if (replyTo.equals(SpecialAddress.NULL)) { + mail.getMessage().setReplyTo(null); + if (mailet.getInitParameters().isDebug()) { + LOGGER.debug("replyTo set to: null"); + } + } else { + mail.getMessage().setReplyTo(new InternetAddress[] { replyTo.toInternetAddress() }); + if (mailet.getInitParameters().isDebug()) { + LOGGER.debug("replyTo set to: {}", replyTo); } } } http://git-wip-us.apache.org/repos/asf/james-project/blob/3ae94d03/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java index f95175f..9abfd7c 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java @@ -87,10 +87,6 @@ public class SpecialAddressesUtils { return ImmutableSet.of(mailAddress); } - if (mailAddress.isNullSender()) { - return ImmutableList.of(); - } - SpecialAddressKind specialAddressKind = SpecialAddressKind.forValue(mailAddress.getLocalPart()); if (specialAddressKind == null) { return ImmutableSet.of(mailAddress); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
