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


##########
components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConfiguration.java:
##########
@@ -464,11 +517,27 @@ public MiloClientConfiguration clone() {
     }
 
     public String toCacheId() {
+        final String cacheId;
         if (this.clientId != null && !this.clientId.isEmpty()) {
-            return this.endpointUri + "|" + this.clientId + "|" + 
this.requestedPublishingInterval;
+            cacheId = this.endpointUri + "|" + this.clientId + "|" + 
this.requestedPublishingInterval;
         } else {
-            return this.endpointUri + "|" + this.requestedPublishingInterval;
+            cacheId = this.endpointUri + "|" + 
this.requestedPublishingInterval;
+        }
+        // endpoints that validate the server certificate differently must not 
share a connection
+        return cacheId + serverCertificateTrustCacheId();
+    }
+
+    private String serverCertificateTrustCacheId() {
+        if (this.certificateValidator != null) {
+            return "|certificateValidator=" + 
Integer.toHexString(System.identityHashCode(this.certificateValidator));

Review Comment:
   ⚠️ **Medium — cache ID collision risk:** `System.identityHashCode` returns a 
32-bit hash that can collide across distinct objects, and is non-deterministic 
across JVM restarts (different JVMs sharing the same connection pool 
configuration, or after a restart, may inadvertently share or fail to share 
connections).
   
   With only one or two validators per JVM, the collision probability is 
negligible in practice. But the contract of the cache ID is to isolate 
connections with *different* trust configurations — a collision would mean two 
endpoints with distinct validators share a connection, silently bypassing the 
validation boundary.
   
   Consider using something more stable: 
`this.certificateValidator.getClass().getName() + "@" + 
Integer.toHexString(System.identityHashCode(this.certificateValidator))`, or 
documenting that the **same validator instance** must be reused for connection 
sharing to work correctly. Not a blocker given the expected cardinality, but 
worth a comment at minimum.



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