rondagostino commented on a change in pull request #9645:
URL: https://github.com/apache/kafka/pull/9645#discussion_r528986190
##########
File path:
clients/src/main/java/org/apache/kafka/clients/admin/ScramMechanism.java
##########
@@ -49,8 +53,11 @@ public static ScramMechanism fromType(byte type) {
* Salted Challenge Response Authentication Mechanism (SCRAM) SASL and
GSS-API Mechanisms, Section 4</a>
*/
public static ScramMechanism fromMechanismName(String mechanismName) {
- ScramMechanism retvalFoundMechanism =
ScramMechanism.valueOf(mechanismName.replace('-', '_'));
- return retvalFoundMechanism != null ? retvalFoundMechanism : UNKNOWN;
+ String normalizedMechanism = mechanismName.replace('-', '_');
+ return Arrays.stream(VALUES)
+ .filter(mechanism -> mechanism.name().equals(normalizedMechanism))
+ .findFirst()
+ .orElse(UNKNOWN);
Review comment:
Ah, you are right: `valueOf()` `Throws: IllegalArgumentException - if
the specified enum type has no constant with the specified name, or the
specified class object does not represent an enum type.`
Thanks for catching/testing for/fixing it.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]