philipnee commented on code in PR #13023: URL: https://github.com/apache/kafka/pull/13023#discussion_r1053900444
########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/SubscriptionState.java: ########## @@ -620,7 +620,12 @@ public synchronized Optional<Integer> preferredReadReplica(TopicPartition tp, lo * @return the removed preferred read replica if set, None otherwise. */ public synchronized Optional<Integer> clearPreferredReadReplica(TopicPartition tp) { - return assignedState(tp).clearPreferredReadReplica(); + final TopicPartitionState topicPartitionState = assignedStateOrNull(tp); + if (topicPartitionState == null) { + return Optional.empty(); + } else { Review Comment: The previous condition was returned, so you don't need the else. -- 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