mjsax commented on code in PR #21110:
URL: https://github.com/apache/kafka/pull/21110#discussion_r2605019995


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:
##########
@@ -699,17 +709,40 @@ public void 
onHeartbeatSuccess(StreamsGroupHeartbeatResponse response) {
             processAssignmentReceived(
                 toTasksAssignment(activeTasks),
                 toTasksAssignment(standbyTasks),
-                toTasksAssignment(warmupTasks)
+                toTasksAssignment(warmupTasks),
+                isGroupReady
             );
-        } else {
-            if (responseData.activeTasks() != null ||
-                responseData.standbyTasks() != null ||
-                responseData.warmupTasks() != null) {
+        } else if (responseData.activeTasks() != null || 
responseData.standbyTasks() != null || responseData.warmupTasks() != null) {
+            throw new IllegalStateException("Invalid response data, task 
collections must be all null or all non-null: "
+                + responseData);
+        } else if (isGroupReady != targetAssignment.isGroupReady) {
+            // If the client did not provide a new assignment, but the group 
is now ready or not ready anymore, so
+            // update the target assignment and reconcile it.
+            processAssignmentReceived(
+                targetAssignment.activeTasks,
+                targetAssignment.standbyTasks,
+                targetAssignment.warmupTasks,
+                isGroupReady
+            );
+        }
+    }
 
-                throw new IllegalStateException("Invalid response data, task 
collections must be all null or all non-null: "
-                    + responseData);
+    private boolean 
isGroupReady(List<StreamsGroupHeartbeatResponseData.Status> statuses) {
+        if (statuses != null) {
+            for (final StreamsGroupHeartbeatResponseData.Status status : 
statuses) {
+                switch 
(StreamsGroupHeartbeatResponse.Status.fromCode(status.statusCode())) {

Review Comment:
   I was just thinking about this, and instead of using UNKNOWN_STATUS, which 
should really never happen, as a newer broker should downgrade and only send 
know status to a certain KS client (ie, certain version), should we treat 
unknown with an exception instead?



-- 
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]

Reply via email to