gnodet commented on code in PR #9629:
URL: https://github.com/apache/camel-quarkus/pull/9629#discussion_r4787495152
##########
extensions/tls-registry/runtime/src/main/java/org/apache/camel/quarkus/core/tls/TlsConfigurationConverter.java:
##########
@@ -101,6 +100,7 @@ static SSLContextParameters convert(TlsConfiguration
tlsConfig, String name, Ver
// Copied on first use, since most components never read it. A
certificate reload replaces this whole
// bean, see TlsRegistryHelper.registerOrUpdateBean
private KeyStore keyStoreCopy;
+ private String keyStorePassword;
Review Comment:
**Thread Safety Concern:** Consider making this field `volatile`
While `keyStoreCopy()` is synchronized, `keyStorePassword` is read in
`getKeyManagers()` outside the synchronized block (lines 141-142). Although the
current code likely works due to the happens-before relationship established by
the synchronized method call, making this field `volatile` would provide
stronger guarantees:
```java
private volatile String keyStorePassword;
```
This ensures that when thread A sets the password in the synchronized
`keyStoreCopy()`, thread B will definitely see the updated value when reading
it in `getKeyManagers()`, even without additional synchronization.
The performance impact of `volatile` is negligible here since:
1. This field is only written once per bean instance
2. It's read infrequently (only when components need key managers)
3. Modern JVMs handle volatile reads very efficiently
This is a defensive programming practice that eliminates any theoretical
visibility concerns under the Java Memory Model.
--
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]