gnodet-bot commented on code in PR #28262:
URL: https://github.com/apache/camel/pull/28262#discussion_r4343358653


##########
components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java:
##########
@@ -177,18 +177,39 @@ protected String createEndpointUri() {
         return "xmpp://" + host + ":" + port + "/" + getParticipant() + 
"?serviceName=" + serviceName;
     }
 
+    /**
+     * Gets the connection of this endpoint's account for the given consumer 
or producer. The endpoints of one account
+     * share its connection (a server keeps one session per account and 
resource); each endpoint keeps its own
+     * participant, room and other settings. Release it with {@link 
#releaseConnection(Object)} when the consumer or
+     * producer stops: the connection is closed when no consumer or producer 
of the account uses it any more.
+     */
+    public XMPPTCPConnection acquireConnection(Object user)
+            throws InterruptedException, IOException, SmackException, 
XMPPException {
+        return getComponent().acquireConnection(this, user);
+    }
+
+    /**
+     * Releases the connection that the given consumer or producer acquired 
with {@link #acquireConnection(Object)}.
+     */
+    public void releaseConnection(Object user) {
+        getComponent().releaseConnection(this, user);
+    }
+
+    /**
+     * The settings that make up the connection of an account: the endpoints 
with the same settings share a connection.
+     */
+    List<Object> getConnectionKey() {
+        return Arrays.asList(host, port == 0 ? 5222 : port, serviceName, user, 
password, resource, login, connectionConfig);

Review Comment:
   `connectionConfig` (a Smack `ConnectionConfiguration`) does not override 
`equals()`/`hashCode()` — it falls back to reference identity. Two endpoints 
with equivalent-but-distinct `ConnectionConfiguration` objects will **not** 
share a connection; each gets its own, bypassing the deduplication. This works 
correctly when the config is a Camel registry singleton (as in the tests with 
`#connectionConfig`), but silently fails when a `RouteBuilder` instantiates a 
fresh `ConnectionConfiguration` per endpoint. Worth documenting in the Javadoc: 
to share a connection, all endpoints of the same account must reference the 
**same** `ConnectionConfiguration` instance.



-- 
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