onobc commented on code in PR #18358:
URL: https://github.com/apache/pulsar/pull/18358#discussion_r1020834623
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ClientConfigurationData.java:
##########
@@ -381,25 +394,22 @@ public void setAuthentication(Authentication
authentication) {
this.authentication = authentication;
}
- /**
- * Set the authentication using auth-related configuration properties if
they are available.
- * <p>
- * The {@code authPluginClassName} and one of {@code authParams} or {@code
authParamMap} must be configured for
- * the authentication to be determined and set.
- *
- * @see AuthenticationFactory#create
- * @throws PulsarClientException if authentication creation fails
- */
- public void setAuthenticationFromPropsIfAvailable() throws
PulsarClientException {
+
+ private void setAuthenticationFromPropsIfAvailable() {
if (StringUtils.isBlank(this.getAuthPluginClassName())
|| (StringUtils.isBlank(this.getAuthParams()) &&
this.getAuthParamMap() == null)) {
return;
}
-
- if (StringUtils.isNotBlank(this.getAuthParams())) {
-
this.setAuthentication(AuthenticationFactory.create(this.getAuthPluginClassName(),
this.getAuthParams()));
- } else if (this.getAuthParamMap() != null) {
-
this.setAuthentication(AuthenticationFactory.create(this.getAuthPluginClassName(),
this.getAuthParamMap()));
+ try {
+ if (StringUtils.isNotBlank(this.getAuthParams())) {
+ this.setAuthentication(
+
AuthenticationFactory.create(this.getAuthPluginClassName(),
this.getAuthParams()));
+ } else if (this.getAuthParamMap() != null) {
+ this.setAuthentication(
+
AuthenticationFactory.create(this.getAuthPluginClassName(),
this.getAuthParamMap()));
+ }
+ } catch (UnsupportedAuthenticationException ex) {
Review Comment:
I would prefer to throw this outward but adding throws to
getAuthentication() would be a breaking change.
--
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]