You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/04/19 02:17:14 UTC
(james-project) branch master updated (a14f829d8a -> 0176130ee6)
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
from a14f829d8a Update config-ssl-tls.xml: Fixed typo in <keystoreType> element and indicate that keytool, by default, now creates PKCS12 format keystores not JKS
new 9b6a1d3b9a JAMES-4030 Carry over Bouncer exceptions
new 0176130ee6 JAMES-4030 Carry over RRT forwardToRemoteAddress exceptions
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../mailetcontainer/impl/JamesMailetContext.java | 3 ++-
.../mailets/RecipientRewriteTableProcessor.java | 9 +++-----
.../transport/mailets/remote/delivery/Bouncer.java | 27 ++++++++--------------
.../mailets/remote/delivery/DeliveryRunnable.java | 2 +-
.../mailets/remote/delivery/MailDelivrer.java | 7 +++++-
5 files changed, 22 insertions(+), 26 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 01/02: JAMES-4030 Carry over Bouncer exceptions
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 9b6a1d3b9aed606bc3c78538291c94404efb85e5
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Apr 15 21:05:52 2024 +0200
JAMES-4030 Carry over Bouncer exceptions
This results on a nack of the underlying mailqueue, thus not loosing the email
---
.../transport/mailets/remote/delivery/Bouncer.java | 27 ++++++++--------------
.../mailets/remote/delivery/DeliveryRunnable.java | 2 +-
.../mailets/remote/delivery/MailDelivrer.java | 7 +++++-
3 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/Bouncer.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/Bouncer.java
index 7ba6556218..a50bc4d7f6 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/Bouncer.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/Bouncer.java
@@ -35,9 +35,12 @@ import org.apache.mailet.AttributeName;
import org.apache.mailet.AttributeValue;
import org.apache.mailet.Mail;
import org.apache.mailet.MailetContext;
+import org.apache.mailet.ProcessingState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.github.fge.lambdas.Throwing;
+
public class Bouncer {
private static final Logger LOGGER = LoggerFactory.getLogger(Bouncer.class);
@@ -53,18 +56,14 @@ public class Bouncer {
this.mailetContext = mailetContext;
}
- public void bounce(Mail mail, Exception ex) {
+ public void bounce(Mail mail, Exception ex) throws MessagingException {
configuration.getBounceProcessor().ifPresentOrElse(
- bounceProcessor -> {
+ Throwing.<ProcessingState>consumer(bounceProcessor -> {
computeErrorCode(ex).ifPresent(mail::setAttribute);
mail.setAttribute(new Attribute(DELIVERY_ERROR, AttributeValue.of(getErrorMsg(ex))));
- try {
- mailetContext.sendMail(mail, bounceProcessor.getValue());
- } catch (MessagingException e) {
- LOGGER.warn("Exception re-inserting failed mail: ", e);
- }
- },
- () -> bounceWithMailetContext(mail, ex));
+ mailetContext.sendMail(mail, bounceProcessor.getValue());
+ }).sneakyThrow(),
+ Throwing.runnable(() -> bounceWithMailetContext(mail, ex)).sneakyThrow());
}
private Optional<Attribute> computeErrorCode(Exception ex) {
@@ -76,18 +75,12 @@ public class Bouncer {
.map(code -> new Attribute(DELIVERY_ERROR_CODE, AttributeValue.of(code)));
}
- private void bounceWithMailetContext(Mail mail, Exception ex) {
+ private void bounceWithMailetContext(Mail mail, Exception ex) throws MessagingException {
if (!mail.hasSender()) {
LOGGER.debug("Null Sender: no bounce will be generated for {}", mail.getName());
} else {
LOGGER.debug("Sending failure message {}", mail.getName());
- try {
- mailetContext.bounce(mail, explanationText(mail, ex));
- } catch (MessagingException me) {
- LOGGER.warn("Encountered unexpected messaging exception while bouncing message", me);
- } catch (Exception e) {
- LOGGER.warn("Encountered unexpected exception while bouncing message", e);
- }
+ mailetContext.bounce(mail, explanationText(mail, ex));
}
}
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRunnable.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRunnable.java
index 2576b0396d..9ae75a0c73 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRunnable.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRunnable.java
@@ -206,7 +206,7 @@ public class DeliveryRunnable implements Disposable {
}
}
- private void handlePermanentFailure(Mail mail, ExecutionResult executionResult) {
+ private void handlePermanentFailure(Mail mail, ExecutionResult executionResult) throws MessagingException {
mail.setAttribute(new Attribute(IS_DELIVERY_PERMANENT_ERROR, AttributeValue.of(true)));
bouncer.bounce(mail, executionResult.getException().orElse(null));
}
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrer.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrer.java
index c086d399b8..3d1f8b2f93 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrer.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/MailDelivrer.java
@@ -218,7 +218,12 @@ public class MailDelivrer {
if (!validUnsentAddresses.isEmpty()) {
if (!invalidAddresses.isEmpty()) {
mail.setRecipients(invalidAddresses);
- bouncer.bounce(mail, sfe);
+ try {
+ bouncer.bounce(mail, sfe);
+ } catch (MessagingException e) {
+ LOGGER.warn("Failed bouncing permanently failed recipients, returning full temporarily failure instead", e);
+ return logAndReturn(mail, ExecutionResult.temporaryFailure(sfe));
+ }
}
mail.setRecipients(validUnsentAddresses);
if (enhancedMessagingException.hasReturnCode()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
(james-project) 02/02: JAMES-4030 Carry over RRT forwardToRemoteAddress exceptions
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 0176130ee6f7795de0ad42f6c9990fddae43e067
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon Apr 15 21:38:32 2024 +0200
JAMES-4030 Carry over RRT forwardToRemoteAddress exceptions
Could lead to mail loss...
---
.../apache/james/mailetcontainer/impl/JamesMailetContext.java | 3 ++-
.../james/transport/mailets/RecipientRewriteTableProcessor.java | 9 +++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/server/mailet/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java b/server/mailet/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
index 232c9947fe..416555e966 100644
--- a/server/mailet/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
+++ b/server/mailet/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
@@ -377,7 +377,8 @@ public class JamesMailetContext implements MailetContext, Configurable, Disposab
@Override
public void sendMail(Mail mail) throws MessagingException {
- sendMail(mail, Optional.ofNullable(mail.getState()).orElse(Mail.DEFAULT));
+ String state = Optional.ofNullable(mail.getState()).orElse(Mail.DEFAULT);
+ sendMail(mail, state);
}
@Override
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
index c5805137f9..b51300c8a7 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
@@ -42,7 +42,6 @@ import org.apache.james.domainlist.api.DomainList;
import org.apache.james.domainlist.api.DomainListException;
import org.apache.james.lifecycle.api.LifecycleUtil;
import org.apache.james.rrt.api.RecipientRewriteTable;
-import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
import org.apache.james.rrt.api.RecipientRewriteTableException;
import org.apache.james.rrt.lib.Mapping;
import org.apache.james.rrt.lib.MappingSource;
@@ -415,14 +414,14 @@ public class RecipientRewriteTableProcessor {
return new Decision(recipient, RrtExecutionResult.success(newMailAddresses));
}
return new Decision(recipient, RrtExecutionResult.success(recipient));
- } catch (ErrorMappingException | RecipientRewriteTableException e) {
+ } catch (Exception e) {
LOGGER.warn("Could not rewrite recipient {}", recipient, e);
return new Decision(recipient, RrtExecutionResult.error(recipient));
}
}
@VisibleForTesting
- List<MailAddress> handleMappings(Mappings mappings, Mail mail, MailAddress recipient) {
+ List<MailAddress> handleMappings(Mappings mappings, Mail mail, MailAddress recipient) throws MessagingException {
boolean isLocal = true;
Map<Boolean, List<MailAddress>> mailAddressSplit = splitRemoteMailAddresses(mappings);
@@ -456,7 +455,7 @@ public class RecipientRewriteTableProcessor {
.stream();
}
- private void forwardToRemoteAddress(Mail mail, MailAddress recipient, Collection<MailAddress> remoteRecipients) {
+ private void forwardToRemoteAddress(Mail mail, MailAddress recipient, Collection<MailAddress> remoteRecipients) throws MessagingException {
if (!remoteRecipients.isEmpty()) {
Mail duplicate = null;
try {
@@ -464,8 +463,6 @@ public class RecipientRewriteTableProcessor {
duplicate.setRecipients(ImmutableList.copyOf(remoteRecipients));
mailetContext.sendMail(duplicate);
LOGGER.info("Mail for {} forwarded to {}", recipient, remoteRecipients);
- } catch (MessagingException ex) {
- LOGGER.warn("Error forwarding mail to {}", remoteRecipients);
} finally {
LifecycleUtil.dispose(duplicate);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org