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:31:00 UTC

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

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

Michael commented on KAFKA-10741:
---------------------------------

I think, since in the transition from _ConsumerConfig_ to _AbstractConfig_ the Properties-Object is interpreted only in it's map-representation, it would be helpful to either:
 # Document, that the Properties-Object should only be used as Map, resp. that the _defaults_ are not considered.
 # Implement a Property-To-Map-Conversion, which takes into consideration, that there might be defaults. (i.e. reads the _propertyNames()_ and copy the resolved values for those.)
 # Not use Property-Objects from the beginning, directly requiring a Map.

> 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.0, 2.6.0, 2.5.1
>            Reporter: Michael
>            Priority: Major
>
> {{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)