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

   # Description
   
   [CAMEL-27168](https://issues.apache.org/jira/browse/CAMEL-27168)
   
   With `markAsRead` (the default) the `google-mail-stream` consumer marks a 
mail as read when its exchange completes, and as unread again when it failed. 
It took the id of the mail from the `CamelGoogleMailId` header at that time. A 
route that removed the headers (for example `removeHeaders("*")` before calling 
another system), or replaced the message, marked nothing as read: the modify 
call failed on the null id, the exception handler logged a WARN, and with the 
default query `is:unread` the same mail was consumed again by every poll, for 
ever. A route that changed the header marked another mail as read.
   
   This is the same defect that CAMEL-27015 (#30168) and CAMEL-27064 (#30227) 
fixed in the object storage and queue consumers, fixed the same way.
   
   Fix: the consumer takes the id of the mail before the exchange is routed (it 
already did, to release the in-progress entry) and passes it to the new 
`processCommit(Exchange, String, String)` and `processRollback(Exchange, 
String, String)`. The former two-argument methods are protected, so they are 
kept, deprecated, and delegate with the header as before. The component page 
and the 4.24 upgrade guide say so.
   
   Tests: `GoogleMailStreamConsumerMarkAsReadTest`, with the 
`FakeGmailClientFactory` of the existing stream tests (a Gmail client on a 
`MockHttpTransport` that answers from an in-memory mailbox). A route that 
removes the headers, and a route that sets the header to another id: the 
consumed mails must be marked as read and got once. Runs (offline, with the 
versions cached on my machine): both tests fail on main (the mail is never 
marked as read and is consumed again by every poll: the mock gets 38 messages 
instead of 1, and 76 instead of 2) and pass with the fix; camel-google-mail 
module tests 66 run, 0 failures (the generate goal of the API component plugin 
left no diff); the new test class 20 times in one JVM: 40 of 40.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-27168](https://issues.apache.org/jira/browse/CAMEL-27168).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built the core modules and camel-google-mail with the formatter and 
import-sort plugins, and copied the component page to the catalog. I did not 
run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to