Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-10534

Modify the AbstractConfig class, convert parameter `originals` type from Map<?, ?> to Map<String, ?> to avoid redundant judgments in the code

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: 2.6.0
    • Fix Version/s: None
    • Component/s: clients
    • Labels:
      None
    • Flags:
      Patch

      Description

      Source Code:

       @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.");
      
      
      

      In source code, I find that originals map key must be a string. 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.

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                linenwei linenwei
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: