[ https://issues.apache.org/jira/browse/KAFKA-10860?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tom Bentley reassigned KAFKA-10860: ----------------------------------- Assignee: Tom Bentley > JmxTool fails with NPE when object-name contains a wildcard > ----------------------------------------------------------- > > Key: KAFKA-10860 > URL: https://issues.apache.org/jira/browse/KAFKA-10860 > Project: Kafka > Issue Type: Bug > Reporter: Bob Barrett > Assignee: Tom Bentley > Priority: Major > > When running JmxTool with a wildcard in the object name, the tool fails with > a NullPointerException: > {code:java} > bin/kafka-run-class kafka.tools.JmxTool --jmx-url > service:jmx:rmi:///jndi/rmi://localhost:7777/jmxrmi --object-name > kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic=* > Trying to connect to JMX url: > service:jmx:rmi:///jndi/rmi://localhost:7777/jmxrmi. > Exception in thread "main" java.lang.NullPointerException at > kafka.tools.JmxTool$.main(JmxTool.scala:194) at > kafka.tools.JmxTool.main(JmxTool.scala) > {code} > It seems that we never populate the `names` variable when the object name > includes a pattern: > {code:java} > var names: Iterable[ObjectName] = null > def namesSet = Option(names).toSet.flatten > def foundAllObjects = queries.toSet == namesSet > val waitTimeoutMs = 10000 > if (!hasPatternQueries) { > val start = System.currentTimeMillis > do { > if (names != null) { > System.err.println("Could not find all object names, retrying") > Thread.sleep(100) > } > names = queries.flatMap((name: ObjectName) => mbsc.queryNames(name, > null).asScala) > } while (wait && System.currentTimeMillis - start < waitTimeoutMs && > !foundAllObjects) > } > if (wait && !foundAllObjects) { > val missing = (queries.toSet - namesSet).mkString(", ") > System.err.println(s"Could not find all requested object names after > $waitTimeoutMs ms. Missing $missing") > System.err.println("Exiting.") > sys.exit(1) > } > val numExpectedAttributes: Map[ObjectName, Int] = > if (!attributesWhitelistExists) > names.map{name: ObjectName => > val mbean = mbsc.getMBeanInfo(name) > (name, mbsc.getAttributes(name, > mbean.getAttributes.map(_.getName)).size)}.toMap > else { > if (!hasPatternQueries) > names.map{name: ObjectName => > val mbean = mbsc.getMBeanInfo(name) > val attributes = mbsc.getAttributes(name, > mbean.getAttributes.map(_.getName)) > val expectedAttributes = > attributes.asScala.asInstanceOf[mutable.Buffer[Attribute]] > .filter(attr => attributesWhitelist.get.contains(attr.getName)) > (name, expectedAttributes.size)}.toMap.filter(_._2 > 0) > else > queries.map((_, attributesWhitelist.get.length)).toMap > } > {code} > We need to add logic to query the object names that match the pattern when a > pattern is part of the input. -- This message was sent by Atlassian Jira (v8.3.4#803005)