davsclaus commented on code in PR #30463:
URL: https://github.com/apache/camel/pull/30463#discussion_r4640217134
##########
components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java:
##########
@@ -170,20 +172,31 @@ protected void doStart() throws Exception {
}
}
+ createdSession = false;
if (session == null && hosts != null) {
// use the session builder to create the cluster
session = createSessionBuilder().build();
+ createdSession = true;
}
- sessionHolder = new CassandraSessionHolder(session);
+ // the endpoint closes only the session it created from its hosts; a
session it was given (session) or looked
+ // up (beanRef) is managed outside, and other endpoints, repositories
or the application can use it
+ sessionHolder = new CassandraSessionHolder(session, !createdSession);
sessionHolder.start();
}
@Override
protected void doStop() throws Exception {
super.doStop();
- sessionHolder.stop();
+ if (sessionHolder != null) {
Review Comment:
Accepted: as the author explains, nothing between building the session and
creating the holder in doStart can fail, so this state cannot occur with the
code at this head.
_Claude Code on behalf of Claus Ibsen_
--
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]