You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Michael (Jira)" <ji...@apache.org> on 2020/11/18 20:22:00 UTC

[jira] [Created] (KAFKA-10741) Kafka ConsumerProperties.addDeserializerToConfig breaks hirarchical property resolution.

Michael created KAFKA-10741:
-------------------------------

             Summary: Kafka ConsumerProperties.addDeserializerToConfig breaks hirarchical property resolution.
                 Key: KAFKA-10741
                 URL: https://issues.apache.org/jira/browse/KAFKA-10741
             Project: Kafka
          Issue Type: Bug
          Components: consumer
    Affects Versions: 2.5.1, 2.6.0, 2.5.0
            Reporter: Michael


{{The Method "addDeserializerToConfig(...)" creates a new Property-Object and attempts to preserve the set-up properties.}}

{{For this it calls _putAll(Map<?, ?> t)_ and by this copies all properties that are part of the old properties object in it's Map-Representation.}}
{code:java}
public static Properties addDeserializerToConfig(Properties properties,
                                                 Deserializer<?> keyDeserializer,
                                                 Deserializer<?> valueDeserializer) {
    Properties newProperties = new Properties();
    newProperties.putAll(properties);
    if (keyDeserializer != null)
        newProperties.put(KEY_DESERIALIZER_CLASS_CONFIG, keyDeserializer.getClass().getName());
    if (valueDeserializer != null)
        newProperties.put(VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer.getClass().getName());
    return newProperties;
}
{code}
{{If you utilize the Properties hirarchical structure, and create Properties like this:}}
{code:java}
public static Properties defaultProperties = createDefaultProperties();

public Properties createProperties(String someKey, String someValue) {
    Properties newProperties(defaultProperties);
    properties.addProperty(someKey, someValue);
}{code}
the properties set in the defaultProperties are stored in the Properties-Member _defaults_ and are not part of the Map-Representation.

{{Thus, if only the Map-Representation is copied, the _defaults_ are lost.}}



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