Skip to content

MINOR: Fixes version lookup exception.#748

Closed
MicahZoltu wants to merge 1 commit into
apache:trunkfrom
MicahZoltu:patch-1
Closed

MINOR: Fixes version lookup exception.#748
MicahZoltu wants to merge 1 commit into
apache:trunkfrom
MicahZoltu:patch-1

Conversation

@MicahZoltu

Copy link
Copy Markdown

Given a schema with 2 versions (0 and 1), if you pass in a version of 2 you will get an OutOfBoundsException instead of an IllegalArgumentException.

This fixes the problem by changing the check from > to >=, which will now return true in the given scenario.

@ijuma

ijuma commented Jan 9, 2016

Copy link
Copy Markdown
Member

Thanks for the PR. Could you please add a test too?

@MicahZoltu

Copy link
Copy Markdown
Author

Test added. Let me know if you want any additional tests.

@ijuma

ijuma commented Jan 11, 2016

Copy link
Copy Markdown
Member

LGTM (assuming that tests pass).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of using length of the versions list, would it make sense to check if the value is greater than the latest version?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't have the full source open in front of me, is there a convenient getter for latest version available already? As far as performance, I believe an array length check is about as fast as it gets short of a constant value. For readability though I think version > versions.latest would be more clear if that is an available thing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This class, ProtoUtils, has public static short latestVersion(int apiKey)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That seems like a reasonable course of action:

if (version < 0 || version > latestVersion(apiKey) {
    throw ...
}

I'll try to make that change this evening.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed.

@granthenke

Copy link
Copy Markdown
Member

Can you change the title of the PR to include "MINOR: "?

Just a few small comments otherwise it looks good.

@MicahZoltu MicahZoltu changed the title Fixes version lookup exception. MINOR: Fixes version lookup exception. Jan 20, 2016
@MicahZoltu

Copy link
Copy Markdown
Author

All outstanding issues addressed and rebased on latest trunk.

@granthenke

Copy link
Copy Markdown
Member

LGTM

@ijuma

ijuma commented Jan 21, 2016

Copy link
Copy Markdown
Member

@ewencp maybe you could review this simple fix?

@ewencp

ewencp commented Jan 22, 2016

Copy link
Copy Markdown
Contributor

Hmm, seems like now we're doing a duplicate check on apiKey ranges. This doesn't seem critical since it's all really cheap, but it seems wasteful.

@MicahZoltu

Copy link
Copy Markdown
Author

@ewencp Yeah, I noticed that when I switched over to using the latestVersion method. However, I believe that the readability/clarity of the code is worth the cost since the checks are incredibly cheap. We could rollback to what I had before if others disagree with that trade-off, in which we just compare against versions.length.

@ewencp

ewencp commented Jan 22, 2016

Copy link
Copy Markdown
Contributor

@Zoltu Sure, that makes sense. LGTM.

@asfgit asfgit closed this in a19729f Jan 22, 2016
efeg pushed a commit to efeg/kafka that referenced this pull request Jan 29, 2020
AnGg98 pushed a commit to AnGg98/kafka that referenced this pull request Jul 25, 2022
With 6f81bb1 merged, we can now use c4.xlarge instances with our system tests, which are much more reliable for spot than m3.xlarge.
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.

4 participants