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

   # Description
   
   [CAMEL-26739](https://issues.apache.org/jira/browse/CAMEL-26739)
   
   A group can be completed by the exchange that creates it, for example with 
`completionSize(1)` or a completion predicate that is true for a group of one 
exchange (CAMEL-7146). Such a group is never added to the repository, so 
`doOnCompletion` does not call `remove()` ("only remove if we have previous 
added"), and a recoverable repository has nothing in its completed store for it.
   
   After the exchange was delivered, `AggregateOnCompletion` still called 
`confirmWithResult`. `JdbcAggregationRepository` found no row, logged `problem 
removing row ... DELETE statement did not return 1 but 0` at ERROR, and 
returned `false`, so the exchange id was added to 
`unconfirmedCompleteExchanges`. That set (CAMEL-17613) is for confirms whose 
completed row is not visible yet; only the recover task removes ids from it, 
and only ids that its scan finds in the completed table. These ids were never 
removed, not by later scans and not by a route stop and start: the set grew by 
one id for each such group until the route was removed, and each such delivery 
logged a false ERROR. `JdbcAggregationRepository` is the only repository in 
Camel that overrides `confirmWithResult`, so it is the one that shows this.
   
   Change: `doOnCompletion` marks the aggregated exchange of a group that was 
never stored (only with a recoverable repository), `onSubmitCompletion` takes 
the mark off before the exchange is handed to 
`AggregationStrategy.onCompletion` and sent, and `AggregateOnCompletion` does 
not confirm such an exchange. Groups that were stored, and recovered exchanges, 
are confirmed as before; a non-recoverable repository is confirmed as before. A 
group completed by its first exchange is still not stored, so if its delivery 
fails it is not recovered: that is unchanged by this PR (the `original != null` 
guard of CAMEL-7146), it only stops confirming something that was never stored. 
Backport candidate (4.18.x and later have the same code): the set grows by one 
id per such group until the route is removed.
   
   Test `JdbcAggregateCompletedByFirstExchangeTest` (H2, as the other JDBC 
aggregation tests): two groups completed by their first exchange and one group 
of two exchanges; the repository records the result of each 
`confirmWithResult`. Only the stored group is confirmed, and its confirm finds 
its row. On main the test fails: the two one-exchange groups are confirmed and 
not found (`Exchanges confirmed but not found in the completed table: [..-1, 
..-3]`), so their ids stay in the set. With the fix 1/1, 20/20 over 20 runs. 
camel-sql module tests: 338 run, 0 failures (offline; 
`SqlFunctionDataSourceTest` excluded, it installs an embedded MariaDB). 
camel-core aggregator tests (`org.apache.camel.processor.aggregator.**` and 
`*Aggregat*Test`): 312 run, 0 failures, 5 skipped.
   
   # 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-26739](https://issues.apache.org/jira/browse/CAMEL-26739).
   
   # 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-sql with the formatter and import-sort 
plugins and ran the tests above; no generated file changes. 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