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

   # Description
   
   [CAMEL-25807](https://issues.apache.org/jira/browse/CAMEL-25807)
   
   A poll of the github2 `commit` consumer read the 100 newest commits of the 
branch, routed those after the last routed commit, and then moved the last 
routed commit to the newest one. When more than 100 commits were pushed between 
two polls (a large merge or push, or the first poll after GitHub was 
unreachable or rate limited for a while), the last routed commit was not among 
the 100 newest, so the older new commits were never routed. Nothing was logged.
   
   Change (in `CommitConsumer.poll`): when there is a last routed commit, the 
poll reads the listing up to it, at most 1000 commits (the number of routed 
commits the consumer already remembers). When the last routed commit is not 
found (it is no longer on the branch, after a force push) or there is none 
(`startingSha=beginning`), only the 100 newest commits are considered, as 
before. That keeps the bound related to 
[CAMEL-21256](https://issues.apache.org/jira/browse/CAMEL-21256) 
(`startingSha=last` with a large history) for those cases. When the last routed 
commit is not found and none of the 100 newest commits is new (for example 
after the branch was reset to an older commit), the consumer continues from the 
newest commit, so that the next polls do not list up to 1000 commits again (10 
requests instead of 1) to look for it.
   
   What users can notice: a poll can route more than 100 commits. A note under 
its own `camel-github2` heading in the 4.24 upgrade guide.
   
   Tests:
   - New `GitHub2CommitConsumerManyNewCommitsTest` (a mocked repository 
listing, as in `GitHub2ConsumerPositionTest`).
     - `everyNewCommitIsRouted` (150 commits pushed after `startingSha=c0`) 
fails without the change: the routed commits are `[c51, ..., c150]` instead of 
`[c1, ..., c150]`.
     - `withoutTheLastCommitOnTheBranchOnlyTheNewest100AreRouted` passes with 
and without the change: the force push case keeps its behaviour.
     - `aBranchResetToRoutedCommitsIsNotListedAgainAtEveryPoll` (after 150 
routed commits the branch is reset to `c100`): the polls after the reset read 
one commit, not the whole branch; without the last-commit step above every poll 
reads all 101 commits (`expected: <1> but was: <101>`). No commit is routed 
twice.
   - With the change the camel-github2 unit tests pass: 17 run, 0 failures, 0 
errors, 0 skipped.
   
   How it was found: a small Z3 model of a polling cursor that moves to the 
newest item of a poll whose answer is cut to the newest M items has a 
counterexample as soon as M+1 items arrive between two polls, and none when the 
poll reads up to the cursor. The camel-jira `newIssues` consumer had the same 
cut; the test above reproduces it on this consumer.
   
   What was not run: a test against GitHub; the full root build.
   
   # 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-25807](https://issues.apache.org/jira/browse/CAMEL-25807).
   
   # 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 and tested camel-github2, including the formatter and import-sort 
plugins. No option and no component page changed. 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