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

   # Description
   
   [CAMEL-25289](https://issues.apache.org/jira/browse/CAMEL-25289)
   
   `IggyProducer` and `IggyFetchRecords` borrowed a client from their pool and 
gave it back only after a successful request. Each failed send or poll kept its 
client borrowed; the pool (commons-pool2 defaults: 8 clients, `borrowObject` 
waits forever) is exhausted after 8 failures, and then every send waits forever 
and the consumer consumes nothing more, also once the server is back. The pools 
were never closed and the factory never closed the clients it destroyed, so 
every stop leaked connections. Also, `startingOffset` is documented with the 
default 0 but the field was `null`: with `autoCommit=false` and no 
`startingOffset` every poll failed with a `NullPointerException`.
   
   This change:
   - the client of a failed request is invalidated (removed from the pool and 
closed, it may be broken); the initialization at start returns its client in a 
`finally`;
   - the consumer waits one second after a failed poll instead of polling again 
in a tight loop (the delay it already uses when suspended);
   - `IggyClientFactory.destroyObject` closes the client, and producers and 
consumers close their pool on stop;
   - `startingOffset` defaults to 0.
   
   Tests:
   - `IggyMockClientTest` (new, no Iggy server: the client factory is replaced 
with Mockito `mockConstruction`, the pool is the real `GenericObjectPool`; 
`mockito-core` added as test dependency): 10 failing sends do not hang, the 
producer closes its client on stop, the consumer discards the client of a 
failed poll, and `autoCommit=false` starts at offset 0.
   - Without the change all 4 fail (`execution timed out after 30000 ms` for 
the 9th send, `expected: <1> but was: <0>` twice, `PollingStrategy[kind=Offset, 
value=null]`).
   - With the change the module suite passes (13 unit tests; the ITs need 
Docker).
   
   Not changed: an idle consumer still polls without delay when the topic is 
empty.
   
   # 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).
   
   # 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 the affected module, including the formatter and 
import-sort plugins. 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