apoorvmittal10 commented on code in PR #18649:
URL: https://github.com/apache/kafka/pull/18649#discussion_r1923370549
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -846,16 +846,15 @@ private ShareGroup getOrMaybeCreateShareGroup(
if (group == null) {
return new ShareGroup(snapshotRegistry, groupId);
+ } else {
+ if (group.type() == SHARE) {
+ return (ShareGroup) group;
+ } else {
+ // We don't support upgrading/downgrading between protocols at
the moment so
+ // we throw an exception if a group exists with the wrong type.
+ throw new GroupIdNotFoundException(String.format("Group %s is
not a share group.", groupId));
+ }
}
-
- if (group.type() != SHARE) {
- // We don't support upgrading/downgrading between protocols at the
moment so
- // we throw an exception if a group exists with the wrong type.
- throw new GroupIdNotFoundException(String.format("Group %s is not
a share group.",
- groupId));
- }
-
- return (ShareGroup) group;
Review Comment:
Why do we want to change this, it's same and without multiple if/else?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -878,22 +877,22 @@ ShareGroup getOrMaybeCreatePersistedShareGroup(
Group group = groups.get(groupId);
if (group == null && !createIfNotExists) {
- throw new IllegalStateException(String.format("Share group %s not
found.", groupId));
+ throw new GroupIdNotFoundException(String.format("Share group %s
not found.", groupId));
}
if (group == null) {
ShareGroup shareGroup = new ShareGroup(snapshotRegistry, groupId);
groups.put(groupId, shareGroup);
return shareGroup;
+ } else {
+ if (group.type() == SHARE) {
+ return (ShareGroup) group;
+ } else {
+ // We don't support upgrading/downgrading between protocols at
the moment so
+ // we throw an exception if a group exists with the wrong type.
+ throw new IllegalStateException(String.format("Group %s is not
a share group.", groupId));
Review Comment:
Seems the only required change is the change in exception here.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2032,11 +2031,10 @@ private
CoordinatorResult<ShareGroupHeartbeatResponseData, CoordinatorRecord> sh
// Get or create the share group.
boolean createIfNotExists = memberEpoch == 0;
- final ShareGroup group = getOrMaybeCreatePersistedShareGroup(groupId,
createIfNotExists);
+ final ShareGroup group = getOrMaybeCreateShareGroup(groupId,
createIfNotExists);
Review Comment:
Why do we want to change this behaviour?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]