You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/11/17 08:29:56 UTC

[GitHub] [pulsar] eolivelli commented on a diff in pull request #18358: [fix][admin] Add support for admin auth via conf props

eolivelli commented on code in PR #18358:
URL: https://github.com/apache/pulsar/pull/18358#discussion_r1024885246


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ClientConfigurationData.java:
##########
@@ -367,16 +370,49 @@ public class ClientConfigurationData implements Serializable, Cloneable {
     @Secret
     private String socks5ProxyPassword;
 
+    /**
+     * Gets the authentication settings for the client.
+     * <p>
+     * If the authentication has not been specified an attempt is made to determine one using auth-related
+     * properties. In this case, the {@code authPluginClassName} and one of {@code authParams} or {@code authParamMap}
+     * must be configured for the authentication to be determined. Otherwise, a default of
+     * {@link AuthenticationDisabled} is returned.
+     *
+     * @return authentication settings for the client
+     */
     public Authentication getAuthentication() {
         if (authentication == null) {
-            this.authentication = AuthenticationDisabled.INSTANCE;
+            setAuthenticationFromPropsIfAvailable();

Review Comment:
   usually it is not a good practice to mutate the state in a "getter".
   
   ClientConfigurationData is a POJO that defines the configuration, it shouldn't perform this kind of operations.
   
   I suggest to move this logic to a new utility method and to not change the getter (that already does some automatic fix up, that we should remove, and simply return AuthenticationDisabled.INSTANCE without updating the field).
   
   Also updating the fields introduces concurrency issues, I think that we shouldn't update the POJO
   



-- 
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-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org