You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2017/01/10 14:18:42 UTC
[27/50] [abbrv] james-project git commit: JAMES-1877 Connect do not
need to catch exception
JAMES-1877 Connect do not need to catch exception
This exception will not cause doDelivery (which is host specific to fail
This allow a more clean error handling, where errors are handled at the doDelivery for one server error
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2a4936d3
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2a4936d3
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2a4936d3
Branch: refs/heads/master
Commit: 2a4936d339e76ba41a684ae024f9ce33193c4646
Parents: 942cdfc
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Dec 2 09:14:02 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Tue Jan 10 15:12:51 2017 +0700
----------------------------------------------------------------------
.../remoteDelivery/DeliveryRunnable.java | 35 ++++++--------------
1 file changed, 11 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/2a4936d3/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java
index f497767..c45e736 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java
@@ -253,6 +253,11 @@ public class DeliveryRunnable implements Runnable {
lastError = handleSendFailException(mail, sfe);
} catch (MessagingException me) {
lastError = handleMessagingException(mail, me);
+ if (configuration.isDebug()) {
+ logger.debug(me.getMessage(), me.getCause());
+ } else {
+ logger.info(me.getMessage());
+ }
}
}
// If we encountered an exception while looping through,
@@ -290,9 +295,7 @@ public class DeliveryRunnable implements Runnable {
try {
transport = (SMTPTransport) session.getTransport(outgoingMailServer);
transport.setLocalHost( props.getProperty("mail.smtp.localhost", configuration.getHeloNameProvider().getHeloName()) );
- if (!connect(outgoingMailServer, transport)) {
- return false;
- }
+ connect(outgoingMailServer, transport);
transport.sendMessage(adaptToTransport(message, transport), addr);
logger.debug("Mail (" + mail.getName() + ") sent successfully to " + outgoingMailServer.getHostName() +
" at " + outgoingMailServer.getHost() + " from " + props.get("mail.smtp.from") + " for " + mail.getRecipients());
@@ -538,27 +541,11 @@ public class DeliveryRunnable implements Runnable {
}
}
- private boolean connect(HostAddress outgoingMailServer, SMTPTransport transport) {
- try {
- if (configuration.getAuthUser() != null) {
- transport.connect(outgoingMailServer.getHostName(), configuration.getAuthUser(), configuration.getAuthPass());
- } else {
- transport.connect();
- }
- return true;
- } catch (MessagingException me) {
- // Any error on connect should cause the mailet to attempt
- // to connect to the next SMTP server associated with this
- // MX record. Just log the exception. We'll worry about
- // failing the message at the end of the loop.
-
- // Also include the stacktrace if debug is enabled. See JAMES-1257
- if (configuration.isDebug()) {
- logger.debug(me.getMessage(), me.getCause());
- } else {
- logger.info(me.getMessage());
- }
- return false;
+ private void connect(HostAddress outgoingMailServer, SMTPTransport transport) throws MessagingException {
+ if (configuration.getAuthUser() != null) {
+ transport.connect(outgoingMailServer.getHostName(), configuration.getAuthUser(), configuration.getAuthPass());
+ } else {
+ transport.connect();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org