[ 
https://issues.apache.org/jira/browse/CAMEL-27895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153275#comment-18153275
 ] 

Guillaume Nodet commented on CAMEL-27895:
-----------------------------------------

This issue is being investigated by a coding agent (on behalf of gnodet).

Two confirmed bugs in camel-mail component:

*Bug 1 (idempotent key leak):* In MailConsumer.retrieveMessages(), when 
createExchange() returns null (mail flagged DELETED or exception), the 
idempotent key added in isValidMessage() is never removed. The addedKey 
variable has no corresponding removeIdempotentKey() call in the null-exchange 
path, permanently blacklisting the mail. Fix: add else { 
removeIdempotentKey(addedKey); } after the null check at line 698.

*Bug 2 (To default depends on option order):* In 
MailConfiguration.setUsername() (lines 503-513), setTo(address) is called only 
when recipients is empty. Since setCc/setBcc add to recipients, URI parameter 
parsing order determines whether a default To is set. Example: 
?cc=a@x&username=u gives no To, ?username=u&cc=a@x sets To. Fix: apply the 
default after all options are resolved.

_Note: This comment was generated by an AI coding agent and requires manual 
verification._

> camel-mail: a failed mail is skipped for good with an idempotentRepository, 
> the To default depends on option order
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27895
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27895
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>            Reporter: Claus Ibsen
>            Assignee: Guillaume Nodet
>            Priority: Minor
>             Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-mail for CAMEL-23832 
> (pull request https://github.com/apache/camel/pull/31159).
> These are separate problems of the component; the descriptions change only 
> documents the current behavior.
> h4. 1. A failed mail is skipped for good with an idempotentRepository
> {{MailConsumer.retrieveMessages}} adds the idempotent key in isValidMessage 
> before createExchange; when createExchange returns null (a mail flagged 
> DELETED, or one that failed with skipFailedMessage or handleFailedMessage), 
> the key is never removed, so every consumer sharing the repository skips the 
> mail for good.
> Proposed change: call removeIdempotentKey when createExchange returns null.
> h4. 2. The To default depends on the order of the options
> {{MailConfiguration.setUsername}} sets To to username(@host) only when no 
> recipient is set yet, so ?cc=a@x&username=u sends without a To, and 
> ?username=u&cc=a@x sends To u@host plus Cc a@x.
> Proposed change: apply the default after all options are set, when to, cc and 
> bcc are empty.
> h4. 3. debugMode sets javax.net.debug as a session property
> createJavaMailProperties puts javax.net.debug=all into the Session 
> properties, where JSSE never reads it (it is a JVM system property).
> Proposed change: remove it, or document -Djavax.net.debug.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to