[ 
https://issues.apache.org/jira/browse/KAFKA-2599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14935835#comment-14935835
 ] 

ASF GitHub Bot commented on KAFKA-2599:
---------------------------------------

GitHub user eribeiro opened a pull request:

    https://github.com/apache/kafka/pull/262

    KAFKA-2599 Metadata#getClusterForCurrentTopics can throw NPE even wit…

    …h null checking

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/eribeiro/kafka KAFKA-2599

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/262.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #262
    
----
commit 960107edf131a710e1af808fe93a6ad8566098a5
Author: Edward Ribeiro <edward.ribe...@gmail.com>
Date:   2015-09-29T20:42:31Z

    KAFKA-2599 Metadata#getClusterForCurrentTopics can throw NPE even with null 
checking

----


> 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. 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)

Reply via email to