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-4103: Fix regression in DumpLogSegments offsets decoder #1807

Closed
wants to merge 2 commits into from

Conversation

hachikuji
Copy link

No description provided.

@@ -257,7 +257,7 @@ object DumpLogSegments {
private def parseGroupMetadata(groupMetadataKey: GroupMetadataKey, payload: ByteBuffer) = {
val groupId = groupMetadataKey.key
val group = GroupMetadataManager.readGroupMessageValue(groupId, payload)
val protocolType = group.protocolType
val protocolType = group.protocolType.getOrElse("NONE")
Copy link
Author

@hachikuji hachikuji Aug 31, 2016

Choose a reason for hiding this comment

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

This is really for empty groups. We could alternatively use "" as the absent protocol type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better to pattern match on the protocol type?

Copy link
Author

Choose a reason for hiding this comment

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

We could I suppose. It will only be None when the group is empty, so maybe I can skip iterating over the members in that case.

Copy link
Author

Choose a reason for hiding this comment

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

@ijuma It seemed a little more straightforward to use a default value, but let me know if you disagree.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal for this code and it was already merged, so fine to stay as is.

My reasoning is that you lose a bit of type safety by converting from Option[String] to a String sentinel value and then doing an equality comparison on it. We should never have a protocol with name "", so unlikely to matter here, but I generally prefer to keep the types for as long as possible as it helps avoid bugs as the code evolves.

As an aside, this regression would never have happened if Scala had a type safe equals by default (a number of libraries have a === which is a type safe version of == as a workaround).

Copy link
Author

Choose a reason for hiding this comment

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

@ijuma Makes sense. I agree it would be awesome if there was stricter type checking for == by default. I can't think of any case where I wouldn't want that.

@ewencp
Copy link
Contributor

ewencp commented Aug 31, 2016

LGTM

@asfgit asfgit closed this in c3b64cc Aug 31, 2016
efeg added a commit to efeg/kafka that referenced this pull request May 29, 2024
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.

3 participants