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

JmxTool throws NPE when --object-name is omitted

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.0
    • Component/s: None
    • Labels:
      None

      Description

      Running the JMX tool without --object-name parameter, results in a NullPointerException:

      $ bin/kafka-run-class.sh kafka.tools.JmxTool  --jmx-url service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/jmxrmi
      ...
      Exception in thread "main" java.lang.NullPointerException
      	at kafka.tools.JmxTool$$anonfun$3.apply(JmxTool.scala:143)
      	at kafka.tools.JmxTool$$anonfun$3.apply(JmxTool.scala:143)
      	at scala.collection.LinearSeqOptimized$class.exists(LinearSeqOptimized.scala:93)
      	at scala.collection.immutable.List.exists(List.scala:84)
      	at kafka.tools.JmxTool$.main(JmxTool.scala:143)
      	at kafka.tools.JmxTool.main(JmxTool.scala)
      

      Documentation of the tool says:

      --object-name <String: name>             A JMX object name to use as a query.  
                                                 This can contain wild cards, and    
                                                 this option can be given multiple   
                                                 times to specify more than one      
                                                 query. If no objects are specified  
                                                 all objects will be queried.
      

      Running the tool with --object-name '', also results in an NPE:

      $ bin/kafka-run-class.sh kafka.tools.JmxTool  --jmx-url service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/jmxrmi --object-name ''
      ...
      Exception in thread "main" java.lang.NullPointerException
      	at kafka.tools.JmxTool$.main(JmxTool.scala:197)
      	at kafka.tools.JmxTool.main(JmxTool.scala)
      

      Runnig the tool with --object-name without an argument, the tool with OptionMissingRequiredArgumentException:

      $ bin/kafka-run-class.sh kafka.tools.JmxTool  --jmx-url service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/jmxrmi --object-name 
      
      Exception in thread "main" joptsimple.OptionMissingRequiredArgumentException: Option object-name requires an argument
      	at joptsimple.RequiredArgumentOptionSpec.detectOptionArgument(RequiredArgumentOptionSpec.java:48)
      	at joptsimple.ArgumentAcceptingOptionSpec.handleOption(ArgumentAcceptingOptionSpec.java:257)
      	at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:513)
      	at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56)
      	at joptsimple.OptionParser.parse(OptionParser.java:396)
      	at kafka.tools.JmxTool$.main(JmxTool.scala:104)
      	at kafka.tools.JmxTool.main(JmxTool.scala)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                huxi_2b huxihx
                Reporter:
                asasvari Attila Sasvari
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: