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

   # Description
   
   [CAMEL-26304](https://issues.apache.org/jira/browse/CAMEL-26304)
   
   The producers and consumers of a `jgroups:` endpoint share the channel the 
endpoint created and count their connects. When a route is removed, the core 
stops the endpoint of its consumer, also when other routes still use it, and 
`JGroupsEndpoint.doStop` closed that channel regardless of the count. A closed 
`JChannel` cannot be used again, so every send of the routes that produce to 
the same uri failed with `IllegalStateException: channel is closed` until the 
removed route was added again. Example: 
`from("direct:orders").to("jgroups:orders")` and `from("jgroups:orders")` on 
one node (as in `JGroupsSharedChannelTest`); removing the consumer route broke 
the producer route. CAMEL-25852 fixed this for the channel of the component; 
the channel an endpoint creates itself was left as it was.
   
   Changes:
   - `JGroupsEndpoint.doStop` closes its own channel only when no producer or 
consumer is connected; otherwise the last one that disconnects closes it once 
the endpoint is stopped (under the existing `connectLock`).
   - `doStart` keeps the endpoint's own channel while it is still open. With 
the change the channel can outlive a stop of the endpoint (the producer still 
uses it), and a restart that created a new channel would leave the old one 
connected to the cluster after both routes stopped.
   - The channel of the component or a `channel` bean is unchanged (CAMEL-26080 
is about not closing those).
   - No option, generated file or upgrade guide change.
   - Backport candidates, for the maintainers to label if wanted (contributors 
cannot set `port/*` labels): camel-4.22.x and 4.18.x have the same `doStop` 
(read, not run).
   
   Tests:
   - New `JGroupsRemoveRouteTest` (two endpoints of one cluster in the JVM, the 
second receives what the producer sends):
     - `removeConsumerRoute` fails on main (3 runs: `IllegalStateException: 
channel is closed` on the send after the removal).
     - `removeBothRoutesClosesTheChannel` fails on main (3 runs: `the producer 
still uses the channel ==> expected: <true> but was: <false>`); with the change 
the channel stays connected after the consumer route is removed and is closed 
after the producer route is removed too.
     - `removeConsumerRouteThenAddItAgain` fails on main (3 runs: `the re-added 
consumer uses the channel of the producer`, main closed the old channel and 
created a new one); it checks that the re-added consumer and the producer use 
the same channel and that the producer keeps working. It also fails (3 runs) 
with the change when `doStart` always creates a new channel.
   - camel-jgroups: 36 tests, 0 failures. The formatter and import-sort plugins 
ran.
   
   How it was found: a code sweep for endpoints whose `doStop` releases 
something that other routes on the same uri still use, after a random 
lifecycle-sequence harness found the same kind of defect in camel-disruptor 
(CAMEL-26286).
   
   # 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-26304) 
filed for the change (usually before you start working on it): 
[CAMEL-26304](https://issues.apache.org/jira/browse/CAMEL-26304).
   
   # 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 camel-jgroups and ran its tests, including the formatter and 
import-sort plugins. 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