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



##########
File path: raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java
##########
@@ -2248,24 +2248,23 @@ public void poll() {
     }
 
     @Override
-    public Long scheduleAppend(int epoch, List<T> records) {
+    public long scheduleAppend(int epoch, List<T> records) {
         return append(epoch, records, false);
     }
 
     @Override
-    public Long scheduleAtomicAppend(int epoch, List<T> records) {
+    public long scheduleAtomicAppend(int epoch, List<T> records) {
         return append(epoch, records, true);
     }
 
-    private Long append(int epoch, List<T> records, boolean isAtomic) {
-        Optional<LeaderState<T>> leaderStateOpt = quorum.maybeLeaderState();
-        if (!leaderStateOpt.isPresent()) {
-            return Long.MAX_VALUE;
-        }
+    private long append(int epoch, List<T> records, boolean isAtomic) {
+        LeaderState<T> leaderState = quorum.<T>maybeLeaderState().orElseThrow(
+            () -> new IllegalStateException("Can not get offset because we are 
not the current leader")

Review comment:
       I think that having an offset is a side effect of appending to the 
accumulator. How about:
   "Cannot append records because the replica is not the leader".

##########
File path: raft/src/main/java/org/apache/kafka/raft/RaftClient.java
##########
@@ -147,8 +147,9 @@ default void beginShutdown() {}
      * @throws org.apache.kafka.common.errors.RecordBatchTooLargeException if 
the size of the records is greater than the maximum

Review comment:
       This comment also applies to the `scheduleAtomicAppend` documentation.
   
   This is for the @return tag but we need to update the documentation about 
returning null.




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