[
https://issues.apache.org/jira/browse/KAFKA-9170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16971894#comment-16971894
]
Guozhang Wang commented on KAFKA-9170:
--------------------------------------
Hello [~o.muravskiy] thanks for reporting this, I looked at the source code and
here's my findings:
All StreamsConfig / ProducerConfig / ConsumerConfig extends from AbstractConfig
whose constructors gets a map, e.g. even in ProducerConfig the constructors are
like:
{code}
public ProducerConfig(Properties props) {
super(CONFIG, props);
}
public ProducerConfig(Map<String, Object> props) {
super(CONFIG, props);
}
{code}
Where the {{props}} passed into super constructor is treated as a map. So your
suggested issue seem to be a universal one across all config objects. On the
other hand, inside AbstractConfig we never treat the props as a map and hence
never call its {{props.getProperty}} functions but rely on the ConfigDef for
default values. So it seems to be that not allowing default values to be passed
in as {{new Properties(defaultProperties)}} is by-design.
> KafkaStreams constructor fails to read configuration from Properties object
> created with default values
> -------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-9170
> URL: https://issues.apache.org/jira/browse/KAFKA-9170
> Project: Kafka
> Issue Type: Bug
> Components: streams
> Affects Versions: 2.3.0
> Reporter: Oleg Muravskiy
> Priority: Major
>
> When the *Properties* object passed in to the *KafkaStreams* constructor is
> created like
>
> {code:java}
> new Properties(defaultProperties){code}
>
> KafkaStreams fails to read properties properly, which in my case results in
> an error:
>
> {noformat}
> org.apache.kafka.common.config.ConfigException: Missing required
> configuration "bootstrap.servers" which has no default
> value.org.apache.kafka.common.config.ConfigException: Missing required
> configuration "bootstrap.servers" which has no default value. at
> org.apache.kafka.common.config.ConfigDef.parseValue(ConfigDef.java:476) at
> org.apache.kafka.common.config.ConfigDef.parse(ConfigDef.java:466) at
> org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:108)
> at
> org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:142)
> at org.apache.kafka.streams.StreamsConfig.<init>(StreamsConfig.java:844) at
> org.apache.kafka.streams.StreamsConfig.<init>(StreamsConfig.java:839) at
> org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:544)
> {noformat}
> This is due to the fact that the constructor that receives the *Properties*
> class:
>
> {code:java}
> public KafkaStreams(final Topology topology,
> final Properties props) {
> this(topology.internalTopologyBuilder, new StreamsConfig(props), new
> DefaultKafkaClientSupplier());
> {code}
> passes *props* into *StreamsConfig*, which ignores the *Properties*
> interface, and only uses the *Map* interface:
>
> {code:java}
> public StreamsConfig(final Map<?, ?> props) {
> this(props, true);
> }
> {code}
> (Note that if you do
> {{props.getProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG)}}, it returns the
> correct value).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)