[
https://issues.apache.org/jira/browse/KAFKA-2599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Edward Ribeiro updated KAFKA-2599:
----------------------------------
Status: Patch Available (was: Open)
> Metadata#getClusterForCurrentTopics can throw NPE even with null checking
> -------------------------------------------------------------------------
>
> Key: KAFKA-2599
> URL: https://issues.apache.org/jira/browse/KAFKA-2599
> Project: Kafka
> Issue Type: Bug
> Components: clients
> Affects Versions: 0.8.2.1
> Reporter: Edward Ribeiro
> Assignee: Edward Ribeiro
> Priority: Minor
> Fix For: 0.8.1.2, 0.9.0.0
>
>
> While working on another issue I have just seen the following:
> {code}
> 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);
> }
> {code}
> 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.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)