You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "mayurbm (via GitHub)" <gi...@apache.org> on 2026/08/19 08:08:11 UTC

[PR] CAMEL-24403: camel-mail: handle MessageRemovedException in processCommit to avoid null cause in error log [camel]

mayurbm opened a new pull request, #25550:
URL: https://github.com/apache/camel/pull/25550

   ## Summary
   
   Fixes [CAMEL-24403](https://issues.apache.org/jira/browse/CAMEL-24403).
   
   When an IMAP message is expunged between fetch time and the on-completion commit callback, `IMAPMessage.setFlag()` throws `MessageRemovedException` whose `getMessage()` returns `null`. This produced:
   
   ```
   Caused by: [javax.mail.MessageRemovedException - null]
   ```
   
   ### Changes
   
   - `MailConsumer.java` - catch `MessageRemovedException` before the generic `MessagingException` handler in `processCommit()`, wrap it with an explicit description so the log always shows a meaningful message:
   
   ```
   Caused by: [javax.mail.MessagingException - Message already removed/expunged on server (no flag update possible)]
   ```
   
   - `MailConsumerCommitExpungedMessageTest.java` (new) - 2 unit tests verifying the fix and that other MessagingExceptions pass through unchanged
   
   ### Test Results
   
   ```
   Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   ### AI Attribution
   
   This contribution was developed with AI assistance using [Claude Code](https://github.com/anthropics/claude-code).
   
   ```
   Co-authored-by: Claude <cl...@anthropic.com>
   ```


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24403: camel-mail: handle MessageRemovedException in processCommit to avoid null cause in error log [camel]

Posted by "mayurbm (via GitHub)" <gi...@apache.org>.
mayurbm closed pull request #25550: CAMEL-24403: camel-mail: handle MessageRemovedException in processCommit to avoid null cause in error log
URL: https://github.com/apache/camel/pull/25550


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-24403: camel-mail: handle MessageRemovedException in processCommit to avoid null cause in error log [camel]

Posted by "mayurbm (via GitHub)" <gi...@apache.org>.
mayurbm commented on PR #25550:
URL: https://github.com/apache/camel/pull/25550#issuecomment-5339441072

   ## JIRA Issue: CAMEL-24403
   
   **Link:** https://issues.apache.org/jira/browse/CAMEL-24403
   **Summary:** camel-mail: MessageRemovedException in processCommit causes null in error log
   **Type:** Bug
   **Component:** camel-mail
   
   ### Problem
   
   When an IMAP message is expunged (deleted by another client or server-side policy) between the time it is fetched by `MailConsumer` and when the on-completion commit callback fires, `IMAPMessage.setFlag()` throws `javax.mail.MessageRemovedException`.
   
   This exception is constructed without a message string so `getMessage()` returns `null`, producing:
   
   ```
   Error occurred during committing mail message: com.sun.mail.imap.IMAPMessage@542a494d. Exchange[B5882D23412732A-0000000000000013]. Caused by: [javax.mail.MessageRemovedException - null]
   ```
   
   ### Stack Trace
   
   ```
   javax.mail.MessageRemovedException
     at com.sun.mail.imap.IMAPMessage.checkExpunged(IMAPMessage.java:280)
     at com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:1110)
     at javax.mail.Message.setFlag(Message.java:596)
     at org.apache.camel.component.mail.MailConsumer.processCommit(MailConsumer.java:506)
     at org.apache.camel.component.mail.MailConsumer$1.onComplete(MailConsumer.java:237)
     at org.apache.camel.support.UnitOfWorkHelper.doneSynchronization(UnitOfWorkHelper.java:104)
     at org.apache.camel.support.UnitOfWorkHelper.doneSynchronizations(UnitOfWorkHelper.java:89)
     at org.apache.camel.impl.engine.DefaultUnitOfWork.done(DefaultUnitOfWork.java:238)
     at org.apache.camel.support.UnitOfWorkHelper.doneUow(UnitOfWorkHelper.java:61)
     at org.apache.camel.impl.engine.CamelInternalProcessor$UnitOfWorkProcessorAdvice.after(CamelInternalProcessor.java:770)
     at org.apache.camel.impl.engine.CamelInternalProcessor$AsyncAfterTask.done(CamelInternalProcessor.java:263)
     at org.apache.camel.AsyncCallback.run(AsyncCallback.java:44)
     at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:193)
     at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64)
     at org.apache.camel.processor.Pipeline.process(Pipeline.java:185)
     at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398)
     at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:83)
     at org.apache.camel.support.AsyncProcessorSupport.process(AsyncProcessorSupport.java:41)
     at org.apache.camel.component.mail.MailConsumer.processExchange(MailConsumer.java:449)
     at org.apache.camel.component.mail.MailConsumer.processBatch(MailConsumer.java:258)
     at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:165)
     at org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:202)
     at org.apache.camel.support.ScheduledPollConsumer.run(ScheduledPollConsumer.java:116)
     at org.apache.camel.pollconsumer.quartz.QuartzScheduledPollConsumerJob.execute(QuartzScheduledPollConsumerJob.java:61)
     at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
     at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
   ```
   
   ### Expected Log After Fix
   
   ```
   Caused by: [javax.mail.MessagingException - Message already removed/expunged on server (no flag update possible)]
   ```


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org