Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

sslavic
Copy link
Member

@sslavic sslavic commented Jul 24, 2015

@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #37 FAILURE
Looks like there's a problem with this pull request

@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #38 FAILURE
Looks like there's a problem with this pull request

@sslavic sslavic changed the title KAFKA-2358 KafkaConsumer.partitionsFor returns empty list for non-existing topic KAFKA-2358 Cluster collection returning methods never return null Jul 24, 2015
@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #39 FAILURE
Looks like there's a problem with this pull request

@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #40 FAILURE
Looks like there's a problem with this pull request

@sslavic sslavic force-pushed the feature/KAFKA-2358 branch 2 times, most recently from 34ad65c to be35ebb Compare July 24, 2015 11:37
@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #41 SUCCESS
This pull request looks good

@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #42 SUCCESS
This pull request looks good

@@ -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)
Copy link
Contributor

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;

Copy link
Member Author

@sslavic sslavic Jan 5, 2017

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.

@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #45 FAILURE
Looks like there's a problem with this pull request

@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #46 FAILURE
Looks like there's a problem with this pull request

@sslavic
Copy link
Member Author

sslavic commented Jul 24, 2015

@ijuma and @eribeiro thanks for reviewing.
@eribeiro your suggestion doesn't seem to compile. Tried with both explicitly setting type for emptyList() and by having compiler infer it - doesn't work with ternary operator.

@sslavic sslavic force-pushed the feature/KAFKA-2358 branch 2 times, most recently from 542e8ea to 182d753 Compare July 24, 2015 17:09
@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #47 FAILURE
Looks like there's a problem with this pull request

@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #48 FAILURE
Looks like there's a problem with this pull request

@asfbot
Copy link

asfbot commented Jul 24, 2015

kafka-trunk-git-pr #49 SUCCESS
This pull request looks good

@sslavic
Copy link
Member Author

sslavic commented Dec 17, 2015

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.

@guozhangwang
Copy link
Contributor

@hachikuji Seems still relevant, could you take a look?

@hachikuji
Copy link
Contributor

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

guozhangwang added a commit to guozhangwang/kafka that referenced this pull request Mar 9, 2016
…reams-tech-preview

HOTFIX: Avoid NPE in StreamsPartitionAssignor
@guozhangwang
Copy link
Contributor

@sslavic Could you rebase and address @hachikuji 's comments?

@asfbot
Copy link

asfbot commented Dec 21, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/318/
Test FAILed (JDK 8 and Scala 2.12).

@sslavic
Copy link
Member Author

sslavic commented Jan 7, 2017

@guozhangwang done

@asfbot
Copy link

asfbot commented Jan 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/593/
Test FAILed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Jan 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/594/
Test PASSed (JDK 8 and Scala 2.11).

@asfbot
Copy link

asfbot commented Jan 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/592/
Test FAILed (JDK 7 and Scala 2.10).

@guozhangwang
Copy link
Contributor

test this please

@asfbot
Copy link

asfbot commented Jan 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/599/
Test PASSed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Jan 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/598/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented Jan 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/600/
Test PASSed (JDK 8 and Scala 2.11).

Copy link
Contributor

@guozhangwang guozhangwang left a 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?

@sslavic
Copy link
Member Author

sslavic commented Feb 7, 2017

@guozhangwang please see in Effective Java, 2nd edition, "Item 43: Return empty arrays or collections, not nulls"

@asfbot
Copy link

asfbot commented Feb 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/1537/
Test PASSed (JDK 8 and Scala 2.11).

@asfbot
Copy link

asfbot commented Feb 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/1534/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented Feb 7, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/1534/
Test FAILed (JDK 8 and Scala 2.12).

@guozhangwang
Copy link
Contributor

@sslavic Sorry for the late reply! And thanks for the pointers. LGTM.

@asfgit asfgit closed this in ca06862 Mar 2, 2017
@guozhangwang
Copy link
Contributor

Merged to trunk (for release version 0.11.0.0).

@ijuma
Copy link
Contributor

ijuma commented Mar 2, 2017

Btw, strictly speaking this is an incompatible change to a public API class.

@guozhangwang
Copy link
Contributor

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

  javadoc {
    include "**/org/apache/kafka/clients/consumer/*"
    include "**/org/apache/kafka/clients/producer/*"
    include "**/org/apache/kafka/common/*"
    include "**/org/apache/kafka/common/errors/*"
    include "**/org/apache/kafka/common/serialization/*"
    include "**/org/apache/kafka/common/config/*"
  }

But question is, should all classes within these packages be considered public.

I think ideally we should have an internals package under o.a.k.clients.producer/consumer which contains classes that we do not want to expose as public, while the parent package only expose ProducerRecord, ConsumerRecord, Producer, Consumer, KafkaProducer, KafkaConsumer etc; and o.a.k.common should not be considered public expcet its errors / seralization / config sub-packages. WDYT?

@asfbot
Copy link

asfbot commented Mar 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/1961/
Test PASSed (JDK 8 and Scala 2.11).

@asfbot
Copy link

asfbot commented Mar 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/1958/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented Mar 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/1959/
Test FAILed (JDK 8 and Scala 2.12).

@ijuma
Copy link
Contributor

ijuma commented May 31, 2017

@guozhangwang sorry for the delay in responding. I agree about having internals packages (we have a few, but this is a bit inconsistent). However, the classes in common have been and should continue to be public. It's too confusing otherwise. If we think it's unlikely that people are relying on the previous behaviour and/or this is like a bug fix, then we should add a note to upgrade.html.

@guozhangwang
Copy link
Contributor

It's too confusing otherwise. If we think it's unlikely that people are relying on the previous behaviour and/or this is like a bug fix, then we should add a note to upgrade.html.

Makes sense.

xiowu0 pushed a commit to xiowu0/kafka that referenced this pull request Dec 3, 2020
Co-authored-by: Ke Hu <kehu@kehu-mn2.linkedin.biz>
wyuka pushed a commit to wyuka/kafka that referenced this pull request Mar 4, 2022
…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>
wyuka pushed a commit to wyuka/kafka that referenced this pull request Mar 28, 2022
…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>
wyuka pushed a commit to wyuka/kafka that referenced this pull request Jun 16, 2022
…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>
rustd pushed a commit to rustd/pranavfinaldemokafka that referenced this pull request Feb 9, 2024
)

Minor revision for KAFKA-14247. Added how the handler is called and constructed to the prototype code path.

Reviewers: John Roesler <vvcephei@apache.org>, Kirk True <kirk@mustardgrain.com>

Co-authored-by: Philip Nee <pnee@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants