jsancio commented on a change in pull request #10913:
URL: https://github.com/apache/kafka/pull/10913#discussion_r660023057



##########
File path: raft/src/main/java/org/apache/kafka/raft/QuorumState.java
##########
@@ -514,6 +514,16 @@ public UnattachedState unattachedStateOrThrow() {
         throw new IllegalStateException("Expected to be Leader, but current 
state is " + state);
     }
 
+    @SuppressWarnings("unchecked")
+    public <T> Optional<LeaderState<T>> maybeLeaderState() {
+        EpochState state = this.state;
+        if (state instanceof  LeaderState) {
+            return Optional.of((LeaderState<T>) state);
+        } else {
+            return Optional.empty();
+        }
+    }

Review comment:
       Thanks you. You read my mind. I was thinking of something similar after 
I left my previous comment.




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


Reply via email to