C0urante commented on code in PR #15597: URL: https://github.com/apache/kafka/pull/15597#discussion_r1540093517
########## clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java: ########## @@ -461,6 +497,25 @@ public void testAutoConfigResolutionWithInvalidConfigProviderClass() { } } + @Test + public void testAutoConfigResolutionWithInvalidConfigProviderClassExcluded() { + System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, ""); + // Test Case: Invalid class for Config Provider + Properties props = new Properties(); + props.put("config.providers", "file"); + props.put("config.providers.file.class", + "org.apache.kafka.common.config.provider.InvalidConfigProvider"); + props.put("testKey", "${test:/foo/bar/testpath:testKey}"); + try { + new TestIndirectConfigResolution(props, Collections.emptyMap()); + fail("Expected a config exception due to invalid props :" + props); + } catch (KafkaException e) { + // deliver the disallowed message first to prevent probing the classloader + assertTrue(e.getMessage().contains(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY)); + // this is good + } Review Comment: Nit: can't we use `assertThrows`? The return value can be used to perform assertions on error messages. ########## clients/src/main/java/org/apache/kafka/common/config/AbstractConfig.java: ########## @@ -547,6 +552,17 @@ private Map<String, String> extractPotentialVariables(Map<?, ?> configMap) { return new ResolvingMap<>(resolvedOriginals, originals); } + private Predicate<String> automaticConfigProvidersFilter() { + String systemProperty = System.getProperty(AUTOMATIC_CONFIG_PROVIDERS_PROPERTY); + if (systemProperty == null) { + return ignored -> true; + } else { + return Arrays.stream(systemProperty.split(",")) Review Comment: Nit: can/should we be more permissive in the parsing logic, to align with how list types are parsed by the AbstractConfig class? ```suggestion return Arrays.stream(systemProperty.split(" *, *")) ``` -- 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