You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Rancho-7 (via GitHub)" <gi...@apache.org> on 2025/02/26 13:31:06 UTC
[PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Rancho-7 opened a new pull request, #19039:
URL: https://github.com/apache/kafka/pull/19039
jira: https://issues.apache.org/jira/browse/KAFKA-18850
`org.apache.kafka.automatic.config.providers = env` is incorrect. According to the source code, the correct value should be the [class name](https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/config/AbstractConfig.java#L616).
fix the doc and add unit test to verify.
<img width="631" alt="11" src="https://github.com/user-attachments/assets/f3f0f19d-8ef5-4950-85e5-3c7c868447a9" />
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "Rancho-7 (via GitHub)" <gi...@apache.org>.
Rancho-7 commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1972872022
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +451,32 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
Review Comment:
Thanks for the review! All fixed.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "Rancho-7 (via GitHub)" <gi...@apache.org>.
Rancho-7 commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1971676812
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +450,33 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
+ props.put("config.providers", "file");
+ props.put("config.providers.file.class", MockFileConfigProvider.class.getName());
+ String id = UUID.randomUUID().toString();
+ props.put("config.providers.file.param.testId", id);
+ props.put("test.key", "${file:/path:key}");
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, "file");
+ assertThrows(ConfigException.class, () -> new TestIndirectConfigResolution(props, Collections.emptyMap()));
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, MockFileConfigProvider.class.getName());
+ TestIndirectConfigResolution config = new TestIndirectConfigResolution(props, Collections.emptyMap());
+ assertEquals("testKey", config.originals().get("test.key"));
+ MockFileConfigProvider.assertClosed(id);
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY,
+ MockFileConfigProvider.class.getName() + "," +
+ "org.apache.kafka.common.config.provider.EnvVarConfigProvider");
Review Comment:
Thanks for pointing that out! I will fix 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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1972812136
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +451,32 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
Review Comment:
we can also use `Map.of()` instead `Collections.emptyMap()`
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #19039:
URL: https://github.com/apache/kafka/pull/19039
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "Rancho-7 (via GitHub)" <gi...@apache.org>.
Rancho-7 commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1971674751
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +450,33 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
+ props.put("config.providers", "file");
Review Comment:
same.
https://github.com/apache/kafka/blob/4b5a16bf6ffcb4322d7c5b35a484ff914397909c/clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java#L522
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1972658599
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +450,33 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
+ props.put("config.providers", "file");
+ props.put("config.providers.file.class", MockFileConfigProvider.class.getName());
+ String id = UUID.randomUUID().toString();
Review Comment:
it is totally fine to use java `UUID` as all we want to do is to generate a random string
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "Rancho-7 (via GitHub)" <gi...@apache.org>.
Rancho-7 commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1971671660
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +450,33 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
+ props.put("config.providers", "file");
+ props.put("config.providers.file.class", MockFileConfigProvider.class.getName());
+ String id = UUID.randomUUID().toString();
Review Comment:
Thanks for the review! I have some questions that I noticed we use Java UUID in some other tests in this file.Should we keep the same approach or not?
https://github.com/apache/kafka/blob/4b5a16bf6ffcb4322d7c5b35a484ff914397909c/clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java#L544
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #19039:
URL: https://github.com/apache/kafka/pull/19039#issuecomment-2687144862
cherry-pick to 4.0
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1972690127
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +451,32 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
Review Comment:
Could you please do a bit refactor on this test?
```java
// case0: MockFileConfigProvider is disallowed by org.apache.kafka.automatic.config.providers
System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, "file");
assertThrows(ConfigException.class, () -> new TestIndirectConfigResolution(Map.of("config.providers", "file",
"config.providers.file.class", MockFileConfigProvider.class.getName()),
Collections.emptyMap()));
// case1: MockFileConfigProvider is allowed by org.apache.kafka.automatic.config.providers
System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, MockFileConfigProvider.class.getName());
var props = Map.of("config.providers", "file",
"config.providers.file.class", MockFileConfigProvider.class.getName(),
"config.providers.file.param.testId", UUID.randomUUID().toString(),
"test.key", "${file:/path:key}");
assertEquals("testKey", new TestIndirectConfigResolution(props, Collections.emptyMap()).originals().get("test.key"));
// case2: MockFileConfigProvider and EnvVarConfigProvider are allowed by org.apache.kafka.automatic.config.providers
System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, MockFileConfigProvider.class.getName()
+ ", " + EnvVarConfigProvider.class.getName());
assertEquals("testKey", new TestIndirectConfigResolution(props,
Collections.emptyMap()).originals().get("test.key"));
```
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "Rancho-7 (via GitHub)" <gi...@apache.org>.
Rancho-7 commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1971676812
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +450,33 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
+ props.put("config.providers", "file");
+ props.put("config.providers.file.class", MockFileConfigProvider.class.getName());
+ String id = UUID.randomUUID().toString();
+ props.put("config.providers.file.param.testId", id);
+ props.put("test.key", "${file:/path:key}");
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, "file");
+ assertThrows(ConfigException.class, () -> new TestIndirectConfigResolution(props, Collections.emptyMap()));
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, MockFileConfigProvider.class.getName());
+ TestIndirectConfigResolution config = new TestIndirectConfigResolution(props, Collections.emptyMap());
+ assertEquals("testKey", config.originals().get("test.key"));
+ MockFileConfigProvider.assertClosed(id);
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY,
+ MockFileConfigProvider.class.getName() + "," +
+ "org.apache.kafka.common.config.provider.EnvVarConfigProvider");
Review Comment:
Thanks for pointing that out! Fixed 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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18850: Fix the docs of org.apache.kafka.automatic.config.providers [kafka]
Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #19039:
URL: https://github.com/apache/kafka/pull/19039#discussion_r1971633273
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +450,33 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
+ props.put("config.providers", "file");
+ props.put("config.providers.file.class", MockFileConfigProvider.class.getName());
+ String id = UUID.randomUUID().toString();
+ props.put("config.providers.file.param.testId", id);
+ props.put("test.key", "${file:/path:key}");
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, "file");
+ assertThrows(ConfigException.class, () -> new TestIndirectConfigResolution(props, Collections.emptyMap()));
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY, MockFileConfigProvider.class.getName());
+ TestIndirectConfigResolution config = new TestIndirectConfigResolution(props, Collections.emptyMap());
+ assertEquals("testKey", config.originals().get("test.key"));
+ MockFileConfigProvider.assertClosed(id);
+
+ System.setProperty(AbstractConfig.AUTOMATIC_CONFIG_PROVIDERS_PROPERTY,
+ MockFileConfigProvider.class.getName() + "," +
+ "org.apache.kafka.common.config.provider.EnvVarConfigProvider");
Review Comment:
`EnvVarConfigProvider.class.getName()`
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +450,33 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
+ props.put("config.providers", "file");
+ props.put("config.providers.file.class", MockFileConfigProvider.class.getName());
+ String id = UUID.randomUUID().toString();
Review Comment:
We could use the UUID class defined by Kafka.
##########
clients/src/test/java/org/apache/kafka/common/config/AbstractConfigTest.java:
##########
@@ -450,6 +450,33 @@ public void testConfigProvidersPropsAsParam() {
MockFileConfigProvider.assertClosed(id);
}
+ @Test
+ public void testAutomaticConfigProvidersWithFullClassName() {
+ Properties props = new Properties();
+ props.put("config.providers", "file");
Review Comment:
We could use `AbstractConfig.CONFIG_PROVIDERS_CONFIG` instead of plaintext.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org