davsclaus commented on code in PR #9986: URL: https://github.com/apache/camel/pull/9986#discussion_r1183685358
########## core/camel-support/src/main/java/org/apache/camel/support/cache/DefaultProducerCache.java: ########## @@ -120,11 +123,20 @@ public Object getSource() { @Override public AsyncProducer acquireProducer(Endpoint endpoint) { + // Try to favor thread locality as some data in the producer's cache may be shared among threads, + // triggering cases of false sharing + if (endpoint == lastUsedEndpoint && endpoint.isSingletonProducer()) { + return lastUsedProducer; + } + try { AsyncProducer producer = producers.acquire(endpoint); if (statistics != null) { statistics.onHit(endpoint.getEndpointUri()); } + lastUsedEndpoint = endpoint; Review Comment: You could potentially have a race condition where thread A changes these 2 fields, and thread B does that as well, and then last endpoint and last producer could get mixed up. -- 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: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org