Description
While working on another issue I have just seen the following:
private Cluster getClusterForCurrentTopics(Cluster cluster) { Collection<PartitionInfo> partitionInfos = new ArrayList<>(); if (cluster != null) { for (String topic : this.topics) { partitionInfos.addAll(cluster.partitionsForTopic(topic)); } } return new Cluster(cluster.nodes(), partitionInfos); }
Well, there's a null check for cluster, but if cluster is null it will throw NPE at the return line by calling cluster.nodes()! So, I put together a quick fix and changed MetadataTest to reproduce this error.