ijuma commented on a change in pull request #9758:
URL: https://github.com/apache/kafka/pull/9758#discussion_r552043767



##########
File path: 
clients/src/main/java/org/apache/kafka/common/requests/FetchResponse.java
##########
@@ -59,136 +60,140 @@
  */
 public class FetchResponse<T extends BaseRecords> extends AbstractResponse {
 
-    public static final long INVALID_HIGHWATERMARK = -1L;
+    public static FetchResponseData.FetchablePartitionResponse 
partitionResponse(Errors error) {
+        return new FetchResponseData.FetchablePartitionResponse()
+                .setErrorCode(error.code())
+                .setHighWatermark(FetchResponse.INVALID_HIGH_WATERMARK)
+                .setLastStableOffset(FetchResponse.INVALID_LAST_STABLE_OFFSET)
+                .setLogStartOffset(FetchResponse.INVALID_LOG_START_OFFSET)
+                .setAbortedTransactions(null)
+                .setRecordSet(MemoryRecords.EMPTY)
+                
.setPreferredReadReplica(FetchResponse.INVALID_PREFERRED_REPLICA_ID);
+    }
+
+    public static final long INVALID_HIGH_WATERMARK = -1L;
     public static final long INVALID_LAST_STABLE_OFFSET = -1L;
     public static final long INVALID_LOG_START_OFFSET = -1L;
     public static final int INVALID_PREFERRED_REPLICA_ID = -1;
 
     private final FetchResponseData data;
-    private final LinkedHashMap<TopicPartition, PartitionData<T>> 
responseDataMap;
+    private final LinkedHashMap<TopicPartition, 
FetchResponseData.FetchablePartitionResponse> partitionData;
+    // lazily instantiate this field
+    private LinkedHashMap<TopicPartition, PartitionData<T>> responseDataMap = 
null;

Review comment:
       I understand. It's a bit hard to understand the end state for this class 
as it stands. We've taken a few intermediate steps to this point. Can we just 
go to the end state now?




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to