DL1231 commented on code in PR #21813:
URL: https://github.com/apache/kafka/pull/21813#discussion_r2957517612


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:
##########
@@ -727,15 +728,20 @@ private void process(final 
StreamsOnAllTasksLostCallbackCompletedEvent event) {
      * (to keep subscription state changes in the background)
      */
     private void process(final ApplyAssignmentEvent event) {
-        if (requestManagers.consumerMembershipManager.isEmpty()) {
-            log.warn("ConsumerMembershipManager not present when processing 
ApplyAssignmentEvent");
-            event.future().completeExceptionally(
-                new IllegalStateException("ConsumerMembershipManager not 
available"));
-            return;
-        }
         try {
-            requestManagers.consumerMembershipManager.get().applyAssignment(
-                event.assignedPartitions(), event.addedPartitions());
+            if (requestManagers.consumerMembershipManager.isPresent()) {
+                
requestManagers.consumerMembershipManager.get().applyAssignment(
+                    event.assignedPartitions(), event.addedPartitions());
+            } else if (requestManagers.streamsMembershipManager.isPresent()) {
+                requestManagers.streamsMembershipManager.get().applyAssignment(
+                    (SortedSet<TopicPartition>) event.assignedPartitions(), 
event.addedPartitions());

Review Comment:
   `ApplyAssignmentEvent` wraps `assignedPartitions` with 
`Collections.unmodifiableSet()` in its constructor, which does not preserve the 
`SortedSet` interface (unlike `Collections.unmodifiableSortedSet()`). So the 
cast `(SortedSet<TopicPartition>) event.assignedPartitions()` will throw 
`ClassCastException` at runtime. 
   
   The unit test masks this because `completeAssignment()` calls 
`membershipManager.applyAssignment()` directly, bypassing the 
`ApplyAssignmentEvent` round-trip.



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