apoorvmittal10 commented on code in PR #14699: URL: https://github.com/apache/kafka/pull/14699#discussion_r1382258656
########## core/src/main/java/kafka/metrics/ClientMetricsConfigs.java: ########## @@ -143,46 +152,43 @@ private static void validateProperties(Properties properties) { /** * Parses the client matching patterns and builds a map with entries that has * (PatternName, PatternValue) as the entries. - * Ex: "VERSION=1.2.3" would be converted to a map entry of (Version, 1.2.3) + * Ex: "VERSION=1.2.3" would be converted to a map entry of (Version, 1.2.3) * <p> - * NOTES: - * Client match pattern splits the input into two parts separated by first occurrence of the character '=' + * NOTES: + * Client match pattern splits the input into two parts separated by first occurrence of the character '=' * - * @param patterns List of client matching pattern strings + * @param patterns List of client matching pattern strings * @return map of client matching pattern entries */ - public static Map<String, String> parseMatchingPatterns(List<String> patterns) { - Map<String, String> patternsMap = new HashMap<>(); - if (patterns != null) { - patterns.forEach(pattern -> { - String[] nameValuePair = pattern.split("="); - if (nameValuePair.length != 2) { - throw new InvalidConfigurationException("Illegal client matching pattern: " + pattern); - } - - String param = nameValuePair[0].trim(); - String patternValue = nameValuePair[1].trim(); - if (isValidParam(param) && isValidRegExPattern(patternValue)) { - patternsMap.put(param, patternValue); - } else { - throw new InvalidConfigurationException("Illegal client matching pattern: " + pattern); - } - }); + public static Map<String, Pattern> parseMatchingPatterns(List<String> patterns) { Review Comment: Moved from <String, String> to <String, Pattern> to avoid reparsing of patterns. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org