Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/539#discussion_r34026647
  
    --- Diff: server/src/com/cloud/api/auth/APIAuthenticationManagerImpl.java 
---
    @@ -52,17 +55,25 @@ public void 
setApiAuthenticators(List<PluggableAPIAuthenticator> authenticators)
     
         @Override
         public boolean start() {
    -        s_authenticators = new HashMap<String, Class<?>>();
    +        initAuthenticator();
             for (Class<?> authenticator: getCommands()) {
                 APICommand command = 
authenticator.getAnnotation(APICommand.class);
                 if (command != null && !command.name().isEmpty()
                         && 
APIAuthenticator.class.isAssignableFrom(authenticator)) {
    -                s_authenticators.put(command.name().toLowerCase(), 
authenticator);
    +                addAuthenticator(authenticator, command);
                 }
             }
             return true;
         }
     
    +    private static synchronized void addAuthenticator(Class<?> 
authenticator, APICommand command) {
    +        s_authenticators.put(command.name().toLowerCase(), authenticator);
    +    }
    +
    +    private static synchronized void initAuthenticator() {
    +        s_authenticators = new ConcurrentHashMap<String, Class<?>>();
    +    }
    +
    --- End diff --
    
    Why not simply ``s_authenticators`` a final instance-level variable 
initialized to ``new ConcurrentHashMap<String, Class<?>>()`` in the default 
constructor?  I see no need for it to be a static since it is never accessed in 
a static context.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to