Repository: kafka Updated Branches: refs/heads/trunk 1110f66fa -> 08b775c32
KAFKA-5608; Follow-up to fix potential NPE and clarify method name Author: Ismael Juma <ism...@juma.me.uk> Reviewers: Ewen Cheslack-Postava <m...@ewencp.org> Closes #3553 from ijuma/kafka-5608-follow-up Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/08b775c3 Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/08b775c3 Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/08b775c3 Branch: refs/heads/trunk Commit: 08b775c322d359e20506069d54f5b92a5a37ce63 Parents: 1110f66 Author: Ismael Juma <ism...@juma.me.uk> Authored: Fri Jul 21 13:42:52 2017 +0100 Committer: Ismael Juma <ism...@juma.me.uk> Committed: Fri Jul 21 13:42:52 2017 +0100 ---------------------------------------------------------------------- core/src/main/scala/kafka/tools/JmxTool.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/08b775c3/core/src/main/scala/kafka/tools/JmxTool.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/tools/JmxTool.scala b/core/src/main/scala/kafka/tools/JmxTool.scala index c83f792..3273821 100644 --- a/core/src/main/scala/kafka/tools/JmxTool.scala +++ b/core/src/main/scala/kafka/tools/JmxTool.scala @@ -127,8 +127,8 @@ object JmxTool extends Logging { val hasPatternQueries = queries.exists((name: ObjectName) => name.isPattern) var names: Iterable[ObjectName] = null - def namesSet = if (names == null) null else names.toSet - def foundAllObjects() = !queries.toSet.equals(namesSet) + def namesSet = Option(names).toSet.flatten + def foundAllObjects = queries.toSet == namesSet val waitTimeoutMs = 10000 if (!hasPatternQueries) { val start = System.currentTimeMillis @@ -138,10 +138,10 @@ object JmxTool extends Logging { Thread.sleep(100) } names = queries.flatMap((name: ObjectName) => mbsc.queryNames(name, null).asScala) - } while (wait && System.currentTimeMillis - start < waitTimeoutMs && foundAllObjects) + } while (wait && System.currentTimeMillis - start < waitTimeoutMs && !foundAllObjects) } - if (wait && 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.")