New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-2358 Cluster collection returning methods never return null #96
Conversation
kafka-trunk-git-pr #37 FAILURE |
kafka-trunk-git-pr #38 FAILURE |
a05ed62
to
9cb31cd
Compare
kafka-trunk-git-pr #39 FAILURE |
kafka-trunk-git-pr #40 FAILURE |
34ad65c
to
be35ebb
Compare
kafka-trunk-git-pr #41 SUCCESS |
kafka-trunk-git-pr #42 SUCCESS |
@@ -151,7 +151,10 @@ public PartitionInfo partition(TopicPartition topicPartition) { | |||
* @return A list of partitions | |||
*/ | |||
public List<PartitionInfo> partitionsForTopic(String topic) { | |||
return this.partitionsByTopic.get(topic); | |||
List<PartitionInfo> parts = this.partitionsByTopic.get(topic); | |||
if (parts == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you could just as well use a ternary operator here:
return (parts == null) ? Collections.<List<PartitionInfo>>emptyList() : parts;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I see why it wasn't compiling, the outer List is not needed, just PartitionInfo type is enough.
Fixed, thanks for the tip.
be35ebb
to
4293cd9
Compare
kafka-trunk-git-pr #45 FAILURE |
4293cd9
to
938e4d3
Compare
kafka-trunk-git-pr #46 FAILURE |
542e8ea
to
182d753
Compare
kafka-trunk-git-pr #47 FAILURE |
kafka-trunk-git-pr #48 FAILURE |
182d753
to
c3df4a5
Compare
kafka-trunk-git-pr #49 SUCCESS |
It's been a while, PR which was passing the build before no longer merges with master without conflict, maybe it's no longer relevant even; needs to be checked and rebased if still relevant. |
@hachikuji Seems still relevant, could you take a look? |
The change LGTM. I think there may be some new usages which need to be updated when rebasing though (e.g. DefaultPartitionGrouper in Kafka Streams still depends on the null value). |
…reams-tech-preview HOTFIX: Avoid NPE in StreamsPartitionAssignor
@sslavic Could you rebase and address @hachikuji 's comments? |
Refer to this link for build results (access rights to CI server needed): |
@guozhangwang done |
ed5dfbd
to
ccf5537
Compare
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
test this please |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. I have a meta question though: what is the benefit of pushing the null check deeper in the Cluster
class than doing it in the caller?
@guozhangwang please see in Effective Java, 2nd edition, "Item 43: Return empty arrays or collections, not nulls" |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
@sslavic Sorry for the late reply! And thanks for the pointers. LGTM. |
Merged to trunk (for release version 0.11.0.0). |
Btw, strictly speaking this is an incompatible change to a public API class. |
Thanks for pointing this out @ijuma , and we have been discussing whether these functions should really be considered public APIs (cc @hachikuji @ewencp ). Currently we have javadocs generated for
But question is, should all classes within these packages be considered public. I think ideally we should have an |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
@guozhangwang sorry for the delay in responding. I agree about having |
Makes sense. |
Co-authored-by: Ke Hu <kehu@kehu-mn2.linkedin.biz>
…pache#278) Co-authored-by: Ke Hu <kehu@kehu-mn2.linkedin.biz> (cherry picked from commit c7b3619) Resolved Merge conflicts and corrected tests The upstream behavior has changed in @KAFKA-8904 and @KAFKA-12257 where now merge is called when cluster ids are different in case of a partial update hence changed the called to validateCluster only when it is not a partial update Co-authored-by: Ke Hu <kehu@linkedin.com>
…pache#278) (cherry picked from commit c7b3619) Resolved Merge conflicts and corrected tests The upstream behavior has changed in @KAFKA-8904 and @KAFKA-12257 where now merge is called when cluster ids are different in case of a partial update hence changed the called to validateCluster only when it is not a partial update Co-authored-by: Ke Hu <kehu@linkedin.com>
…pache#278) (cherry picked from commit c7b3619) Resolved Merge conflicts and corrected tests The upstream behavior has changed in @KAFKA-8904 and @KAFKA-12257 where now merge is called when cluster ids are different in case of a partial update hence changed the called to validateCluster only when it is not a partial update Co-authored-by: Ke Hu <kehu@linkedin.com>
See https://issues.apache.org/jira/browse/KAFKA-2358