smiklosovic commented on code in PR #4427:
URL: https://github.com/apache/cassandra/pull/4427#discussion_r2976588416


##########
src/java/org/apache/cassandra/auth/CassandraRoleManager.java:
##########
@@ -171,17 +173,16 @@ public CassandraRoleManager()
 
     public CassandraRoleManager(Map<String, String> parameters)
     {
-        Set<Option> allowedOptions = DatabaseDescriptor.getAuthenticator() 
instanceof PasswordAuthenticator
-                                     ? EnumSet.of(Option.LOGIN, 
Option.SUPERUSER, Option.PASSWORD, Option.HASHED_PASSWORD, 
Option.GENERATED_PASSWORD, Option.GENERATED_NAME)
-                                     : EnumSet.of(Option.LOGIN, 
Option.SUPERUSER);
+        Set<Option> allowedOptions = 
Stream.concat(DEFAULT_SUPPORTED_ROLE_OPTIONS.stream(), 
DatabaseDescriptor.getAuthenticator().getSupportedRoleOptions().stream())
+                                           .collect(Collectors.toSet());
 
         if (Guardrails.roleNamePolicy.getGenerator() != NoOpGenerator.INSTANCE)
             allowedOptions.add(Option.OPTIONS);
 
-        supportedOptions = ImmutableSet.copyOf(allowedOptions);
-        alterableOptions = DatabaseDescriptor.getAuthenticator() instanceof 
PasswordAuthenticator
-                           ? ImmutableSet.of(Option.PASSWORD, 
Option.HASHED_PASSWORD, Option.GENERATED_PASSWORD)
-                           : ImmutableSet.<Option>of();
+        supportedOptions = Set.copyOf(allowedOptions);

Review Comment:
   I am just wondering why are we copying here? What is wrong with just 
directly assign the result of above Stream.concat .... into `supportedOptions`? 
What is the added value here?



##########
src/java/org/apache/cassandra/auth/CassandraRoleManager.java:
##########
@@ -171,17 +173,16 @@ public CassandraRoleManager()
 
     public CassandraRoleManager(Map<String, String> parameters)
     {
-        Set<Option> allowedOptions = DatabaseDescriptor.getAuthenticator() 
instanceof PasswordAuthenticator
-                                     ? EnumSet.of(Option.LOGIN, 
Option.SUPERUSER, Option.PASSWORD, Option.HASHED_PASSWORD, 
Option.GENERATED_PASSWORD, Option.GENERATED_NAME)
-                                     : EnumSet.of(Option.LOGIN, 
Option.SUPERUSER);
+        Set<Option> allowedOptions = 
Stream.concat(DEFAULT_SUPPORTED_ROLE_OPTIONS.stream(), 
DatabaseDescriptor.getAuthenticator().getSupportedRoleOptions().stream())
+                                           .collect(Collectors.toSet());
 
         if (Guardrails.roleNamePolicy.getGenerator() != NoOpGenerator.INSTANCE)
             allowedOptions.add(Option.OPTIONS);
 
-        supportedOptions = ImmutableSet.copyOf(allowedOptions);
-        alterableOptions = DatabaseDescriptor.getAuthenticator() instanceof 
PasswordAuthenticator
-                           ? ImmutableSet.of(Option.PASSWORD, 
Option.HASHED_PASSWORD, Option.GENERATED_PASSWORD)
-                           : ImmutableSet.<Option>of();
+        supportedOptions = Set.copyOf(allowedOptions);

Review Comment:
   I am just wondering why are we copying here? What is wrong with just 
directly assigning the result of above Stream.concat .... into 
`supportedOptions`? What is the added value here?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to