JAMES-1877 Avoid inspection for SFE known and present on the ClassPath This actually should improve the way return code is handled
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/aec9b2fc Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/aec9b2fc Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/aec9b2fc Branch: refs/heads/master Commit: aec9b2fc40b3f508c926a4432197a00a4aa0c540 Parents: b299e32 Author: Benoit Tellier <[email protected]> Authored: Wed Dec 7 10:02:52 2016 +0700 Committer: Benoit Tellier <[email protected]> Committed: Tue Jan 10 18:14:26 2017 +0700 ---------------------------------------------------------------------- .../remoteDelivery/EnhancedMessagingException.java | 15 +++++++++++++++ .../mailets/remoteDelivery/MailDelivrerTest.java | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/aec9b2fc/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java index 44b40bd..61a7152 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java @@ -28,6 +28,9 @@ import javax.mail.internet.InternetAddress; import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.base.Preconditions; +import com.sun.mail.smtp.SMTPAddressFailedException; +import com.sun.mail.smtp.SMTPSendFailedException; +import com.sun.mail.smtp.SMTPSenderFailedException; public class EnhancedMessagingException { @@ -76,6 +79,18 @@ public class EnhancedMessagingException { } private Optional<Integer> computeReturnCode() { + if (messagingException instanceof SMTPAddressFailedException) { + SMTPAddressFailedException addressFailedException = (SMTPAddressFailedException) this.messagingException; + return Optional.of(addressFailedException.getReturnCode()); + } + if (messagingException instanceof SMTPSendFailedException) { + SMTPSendFailedException sendFailedException = (SMTPSendFailedException) this.messagingException; + return Optional.of(sendFailedException.getReturnCode()); + } + if (messagingException instanceof SMTPSenderFailedException) { + SMTPSenderFailedException senderFailedException = (SMTPSenderFailedException) this.messagingException; + return Optional.of(senderFailedException.getReturnCode()); + } if (messagingException.getClass().getName().endsWith(".SMTPSendFailedException") || messagingException.getClass().getName().endsWith(".SMTPAddressSucceededException")) { try { http://git-wip-us.apache.org/repos/asf/james-project/blob/aec9b2fc/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrerTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrerTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrerTest.java index c96e9a1..477d945 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrerTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/MailDelivrerTest.java @@ -33,7 +33,6 @@ import org.apache.mailet.Mail; import org.apache.mailet.base.MailAddressFixture; import org.apache.mailet.base.test.FakeMail; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,7 +71,6 @@ public class MailDelivrerTest { assertThat(executionResult).isEqualTo(ExecutionResult.temporaryFailure(sfe)); } - @Ignore("Return code is always ignored") @Test public void handleSenderFailedExceptionShouldReturnPermanentFailureWhenServerException() throws Exception { Mail mail = FakeMail.builder().recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES).build(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
