You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Will LaForst (Jira)" <ji...@apache.org> on 2020/06/06 15:34:00 UTC

[jira] [Commented] (KAFKA-5514) KafkaConsumer ignores default values in Properties object because of incorrect use of Properties object.

    [ https://issues.apache.org/jira/browse/KAFKA-5514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17127377#comment-17127377 ] 

Will LaForst commented on KAFKA-5514:
-------------------------------------

I think the misuse of propertlies can be linked to this function inside of [org.apache.kafka.common.utils.Utils.propsToMap|https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/utils/Utils.java]. 

{code:java}
public static Map<String, Object> propsToMap(Properties properties) {
        Map<String, Object> map = new HashMap<>(properties.size());
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            if (entry.getKey() instanceof String) {
                String k = (String) entry.getKey();
                map.put(k, properties.get(k));
            } else {
                throw new ConfigException(entry.getKey().toString(), entry.getValue(), "Key must be a string.");
            }
        }
        return map;
    }
{code}
 
 Instead iterating over properties.entrySet it should iterate over properties.propertyNames() which will include the keys from the backing default Properties object.

> KafkaConsumer ignores default values in Properties object because of incorrect use of Properties object.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-5514
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5514
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients
>    Affects Versions: 0.10.2.1
>            Reporter: Geert Schuring
>            Priority: Major
>
> When setting default values in a Properties object the KafkaConsumer ignores these values because the Properties object is being treated as a Map. The ConsumerConfig object uses the putAll method to copy properties from the incoming object to its local copy. (See https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerConfig.java#L471)
> This is incorrect because it only copies the explicit properties and ignores the default values also present in the properties object. (Also see: https://stackoverflow.com/questions/2004833/how-to-merge-two-java-util-properties-objects)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)