You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2022/05/06 13:42:36 UTC
[GitHub] [zookeeper] sonatype-lift[bot] commented on a diff in pull request #1839: ZOOKEEPER-3806: TLS - dynamic loading for client trust/key store
sonatype-lift[bot] commented on code in PR #1839:
URL: https://github.com/apache/zookeeper/pull/1839#discussion_r866842149
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/auth/ProviderRegistry.java:
##########
@@ -55,21 +55,27 @@ public static void initialize() {
Enumeration<Object> en = System.getProperties().keys();
while (en.hasMoreElements()) {
String k = (String) en.nextElement();
- if (k.startsWith(AUTHPROVIDER_PROPERTY_PREFIX)) {
- String className = System.getProperty(k);
- try {
- Class<?> c = ZooKeeperServer.class.getClassLoader().loadClass(className);
- AuthenticationProvider ap = (AuthenticationProvider) c.getDeclaredConstructor().newInstance();
- authenticationProviders.put(ap.getScheme(), ap);
- } catch (Exception e) {
- LOG.warn("Problems loading {}", className, e);
- }
- }
+ addOrUpdateProvider(k);
}
initialized = true;
}
}
+ public static void addOrUpdateProvider(String authKey) {
+ synchronized (ProviderRegistry.class) {
+ if (authKey.startsWith(AUTHPROVIDER_PROPERTY_PREFIX)) {
+ String className = System.getProperty(authKey);
+ try {
+ Class<?> c = ZooKeeperServer.class.getClassLoader().loadClass(className);
+ AuthenticationProvider ap = (AuthenticationProvider) c.getDeclaredConstructor().newInstance();
+ authenticationProviders.put(ap.getScheme(), ap);
+ } catch (Exception e) {
+ LOG.warn("Problems loading {}", className, e);
+ }
+ }
+ }
+ }
+
public static ServerAuthenticationProvider getServerProvider(String scheme) {
return WrappedAuthenticationProvider.wrap(getProvider(scheme));
Review Comment:
*THREAD_SAFETY_VIOLATION:* Read/Write race. Non-private method `ProviderRegistry.getServerProvider(...)` indirectly reads without synchronization from `auth.ProviderRegistry.initialized`. Potentially races with write in method `ProviderRegistry.reset()`.
Reporting because another access to the same memory occurs on a background thread, although this access may not.
(at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
---
Was this a good recommendation?
[ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=205172643&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=205172643&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=205172643&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=205172643&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=205172643&lift_comment_rating=5) ]
--
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: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org