You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Ksolves India Limited (Jira)" <ji...@apache.org> on 2025/09/02 08:36:00 UTC

[jira] [Commented] (KAFKA-10534) Modify the AbstractConfig class, convert parameter `originals` type from Map to Map to avoid redundant judgments in the code

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

Ksolves India Limited commented on KAFKA-10534:
-----------------------------------------------

We keep the parameter as Map<?, ?> instead of Map<String, ?> to allow flexibility with
config sources like java.util.Properties (typed as Map<Object,Object>) and other legacy
callers. The runtime check ensures keys are Strings while maintaining backward compatibility.

> Modify the AbstractConfig  class,  convert parameter `originals` type from Map<?, ?> to Map<String, ?>  to avoid redundant judgments in the code
> ------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-10534
>                 URL: https://issues.apache.org/jira/browse/KAFKA-10534
>             Project: Kafka
>          Issue Type: Improvement
>          Components: clients
>    Affects Versions: 2.6.0
>            Reporter: linenwei
>            Assignee: Ksolves India Limited
>            Priority: Trivial
>
> Source Code:
> {code:java}
>  @SuppressWarnings("unchecked")    
>   public AbstractConfig(ConfigDef definition, Map<?, ?> originals,  Map<String, ?> configProviderProps, boolean doLog){ 
>      /* check that all the keys are really strings */        
>       for (Map.Entry<?, ?> entry : originals.entrySet())            
>           if (!(entry.getKey() instanceof String))               
>               throw new ConfigException(entry.getKey().toString(),       entry.getValue(), "Key must be a string.");
> {code}
> In source code, I find that originals map key {color:#FF0000}must be a string{color}. From my point of view,  why not use Map<String, ?> originals to replace Map<?, ?> originals? thus will not need to do a judgement for the key type. 
> I'm not sure if I've thought about it, but if there are other reasons for doing this, I'd love to know why.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)