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

Fix inconsistent behavior in LongPairRangeSet #10713

Merged
merged 5 commits into from
May 26, 2021

Conversation

315157973
Copy link
Contributor

Motivation

Now LongPairRangeSet has two implementation classes: ConcurrentOpenLongPairRangeSet and DefaultRangeSet
But their behavior in some methods is inconsistent, such as: firstRange, lastRange

If there is no data, in ConcurrentOpenLongPairRangeSet, the above two methods will return null.
NoSuchElementException will be thrown in DefaultRangeSet, which is the default behavior of Guava Range.

When I was using this interface, it was very troublesome to deal with abnormal scenarios. I needed to determine whether it was null and add try-catch, so it is better to make the behavior of the current implementation class consistent.

Either throw an exception or return null, I chose to return null

Modifications

Verifying this change

@codelipenghui codelipenghui added this to the 2.8.0 milestone May 26, 2021
@codelipenghui codelipenghui added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label May 26, 2021
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

overall looks good to me, but please take a look to my comment about the tests

@merlimat merlimat merged commit 4b2c673 into apache:master May 26, 2021
yangl pushed a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
* fix inconsistent behavior

* add unit test

* fix unit test

* add unit test
@315157973 315157973 deleted the behavior branch July 19, 2021 11:11
eolivelli pushed a commit to datastax/pulsar that referenced this pull request Nov 24, 2021
* fix inconsistent behavior

* add unit test

* fix unit test

* add unit test

(cherry picked from commit 4b2c673)
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
* fix inconsistent behavior

* add unit test

* fix unit test

* add unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants