davsclaus commented on code in PR #27990:
URL: https://github.com/apache/camel/pull/27990#discussion_r4302184994
##########
components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java:
##########
@@ -266,8 +278,32 @@ public String toString() {
// process the exchange
processExchange(exchange);
}
+ }
- return total;
+ /**
+ * Gives back exchanges that are not routed: removes the key of each mail
from the idempotent repository (where
+ * {@link #isValidMessage(String, Message)} added it when the mail was
retrieved), so the mail is not skipped as a
+ * duplicate later, and releases the exchange.
+ */
+ private void releaseNotRouted(Queue<Exchange> notRouted) {
+ Exchange exchange;
+ while ((exchange = notRouted.poll()) != null) {
+ removeIdempotentKey(exchange.getProperty(MAIL_MESSAGE_UID,
String.class));
+ releaseExchange(exchange, true);
Review Comment:
@allthingssecurity, could you apply this suggestion before we merge? It is
the same give-back path the PR fixes: if `releaseExchange` throws, the `while`
loop ends and the remaining mails of the batch keep their idempotent keys,
which is the leak this PR removes. `removeIdempotentKey` just above is already
guarded the same way. The other note (the key of the exchange that
`processExchange` throws on) can be a follow-up.
_Claude Code on behalf of Claus Ibsen_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]