Skip to content

Conversation

@abbccdda
Copy link
Contributor

@abbccdda abbccdda commented Feb 1, 2021

As mentioned in the ticket, returning null for consumer#partitionsFor is not a good client side agreement. Addressing this problem by returning the empty list instead.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to eliminate null from Public APIs.

one (unrelated) question is left.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious.

Is it possible that an existent topic has no partitions? If so, returning empty list may confuse users who querying nonexistent topic. Maybe we should throw UnknownTopicOrPartitionException for nonexistent topic and return empty list for existent topic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, it is worth writing docs for this case (return empty list).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you could have a topic with 0 partition.

@abbccdda abbccdda force-pushed the null-partition-for-KAFKA-12260 branch from d6673be to 521460e Compare February 7, 2021 17:58
@chia7712
Copy link
Member

chia7712 commented Feb 8, 2021

@abbccdda Thanks for updating code. Two minor comments are left.

  1. The docs of KafkaConsumer#partitionsFor(String topic, Duration timeout) is not updated.
  2. MockConsumer still return null when topic is nonexistent. Should we make it return empty collection as well?

@abbccdda
Copy link
Contributor Author

abbccdda commented Feb 8, 2021

@chia7712 Sounds good

@abbccdda abbccdda force-pushed the null-partition-for-KAFKA-12260 branch 2 times, most recently from ac8000e to 02e5491 Compare May 24, 2021 21:45
@abbccdda abbccdda force-pushed the null-partition-for-KAFKA-12260 branch from 02e5491 to 8054053 Compare May 24, 2021 23:49
@abbccdda abbccdda merged commit e4f2f6f into apache:trunk May 26, 2021
ijuma added a commit to ijuma/kafka that referenced this pull request May 27, 2021
…nups

* apache-github/trunk:
MINOR: Adjust parameter ordering of `waitForCondition` and
`retryOnExceptionWithTimeout` (apache#10759)
KAFKA-12796: Removal of deprecated classes under streams-scala
(apache#10710)
KAFKA-12819: Add assert messages to MirrorMaker tests plus other
quality of life improvements (apache#10762)
  Update implementation.html (apache#10771)
  MINOR: Log constructor: Flip logical NOT for readability (apache#10756)
MINOR: deprecate TaskMetadata constructor and add KIP-740 notes to
upgrade guide (apache#10755)
  MINOR: Log more information when producer snapshot is written (apache#10757)
  KAFKA-12260: Avoid hitting NPE for partitionsFor (apache#10017)
MINOR: add window verification to sliding-window co-group test
(apache#10745)
KAFKA-12800: Configure generator to fail on trailing JSON tokens
(apache#10717)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants