chia7712 commented on code in PR #17989:
URL: https://github.com/apache/kafka/pull/17989#discussion_r1866397636
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerHeartbeatRequestManagerTest.java:
##########
@@ -602,6 +602,44 @@ public void testHeartbeatResponseOnErrorHandling(final
Errors error, final boole
}
}
+ @Test
+ public void testUnsupportedVersion() {
+ mockErrorResponse(Errors.UNSUPPORTED_VERSION,
Errors.UNSUPPORTED_VERSION.message());
+ ArgumentCaptor<ErrorEvent> errorEventArgumentCaptor =
ArgumentCaptor.forClass(ErrorEvent.class);
+ verify(backgroundEventHandler).add(errorEventArgumentCaptor.capture());
+ ErrorEvent errorEvent = errorEventArgumentCaptor.getValue();
+
+ // UnsupportedApiVersion in HB response without any custom message.
It's considered as new protocol not supported.
+ String hbNotSupportedMsg = "The cluster does not support the new
consumer group protocol. Set group" +
+ ".protocol=classic on the consumer configs to revert to the
classic protocol until the cluster is upgraded.";
+ assertInstanceOf(Errors.UNSUPPORTED_VERSION.exception().getClass(),
errorEvent.error());
+ assertEquals(hbNotSupportedMsg, errorEvent.error().getMessage());
+ clearInvocations(backgroundEventHandler);
+
+ // UnsupportedApiVersion in HB response with custom message. Specific
to required version not present, should
+ // keep the custom message.
+ String hbVersionNotSupportedMsg = "The cluster does not support
resolution of SubscriptionPattern on version 0. " +
Review Comment:
Do we have a guard on the server side? I assumed that the
`SubscriptionPattern` check would be within
`throwIfConsumerGroupHeartbeatRequestIsInvalid`, but I was unable to locate it.
https://github.com/apache/kafka/blob/6fd951a9c0aa773060cd6bbf8a8b8c47ee9d2965/group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java#L1153
##########
clients/src/main/java/org/apache/kafka/common/requests/ConsumerGroupHeartbeatRequest.java:
##########
@@ -59,6 +60,9 @@ public Builder(ConsumerGroupHeartbeatRequestData data,
boolean enableUnstableLas
@Override
public ConsumerGroupHeartbeatRequest build(short version) {
+ if (version == 0 && data.subscribedTopicRegex() != null) {
+ throw new UnsupportedVersionException("Broker does not support
resolution of SubscriptionPattern on version " + version);
Review Comment:
Pardon me, why do we need to handle the version check manually instead of
relying on the generated code? Alternatively, is this PR intended to add more
meaningful error messages? If so, could you please include the explicit valid
version number (or broker version) in the error message?
--
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]