dajac commented on code in PR #19856: URL: https://github.com/apache/kafka/pull/19856#discussion_r2126508197
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerHeartbeatRequestManagerTest.java: ########## @@ -1009,6 +1009,28 @@ public void testRegexInJoiningHeartbeat() { assertNull(data.subscribedTopicRegex()); } + @Test + public void testRackIdInHeartbeatLifecycle() { + heartbeatState = new HeartbeatState(subscriptions, membershipManager, DEFAULT_MAX_POLL_INTERVAL_MS); + createHeartbeatRequestStateWithZeroHeartbeatInterval(); + + // Initial heartbeat with rackId + mockJoiningMemberData(null); + when(membershipManager.rackId()).thenReturn(Optional.of("rack1")); + ConsumerGroupHeartbeatRequestData data = heartbeatState.buildRequestData(); + assertEquals("rack1", data.rackId()); + + // RackId not included in HB if not updated + when(membershipManager.state()).thenReturn(MemberState.STABLE); + data = heartbeatState.buildRequestData(); + assertNull(data.rackId()); + + // Empty rackId not included in HB + when(membershipManager.rackId()).thenReturn(Optional.empty()); + data = heartbeatState.buildRequestData(); + assertNull(data.rackId()); + } Review Comment: Should we verify that it is sent if all fields are sent again? ########## clients/src/main/java/org/apache/kafka/clients/GroupRebalanceConfig.java: ########## @@ -53,8 +54,14 @@ public GroupRebalanceConfig(AbstractConfig config, ProtocolType protocolType) { // Consumer and Connect use different config names for defining rebalance timeout if ((protocolType == ProtocolType.CONSUMER) || (protocolType == ProtocolType.SHARE)) { this.rebalanceTimeoutMs = config.getInt(CommonClientConfigs.MAX_POLL_INTERVAL_MS_CONFIG); + // Connect doesn't support rack id. + // The GroupCoordinatorService throws error if the rackId is empty. The default value of client.rack is empty string. + // Skip empty rackId to avoid InvalidRequestException. Review Comment: nit: We can remove this comment now. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org