@@ -2309,9 +2309,15 @@ private ListOffsetsRequest createListOffsetRequest(short version) {
23092309 .setTimestamp (1000000L )
23102310 .setCurrentLeaderEpoch (5 );
23112311
2312- ListOffsetsTopic topic = new ListOffsetsTopic ()
2313- .setName ("test" )
2314- .setPartitions (singletonList (partition ));
2312+ ListOffsetsTopic topic = new ListOffsetsTopic ();
2313+ // Version 12+ requires topic ID instead of topic name
2314+ if (version >= 12 ) {
2315+ topic .setTopicId (Uuid .randomUuid ());
2316+ } else {
2317+ topic .setName ("test" );
2318+ }
2319+ topic .setPartitions (singletonList (partition ));
2320+
23152321 return ListOffsetsRequest .Builder
23162322 .forConsumer (true , IsolationLevel .READ_COMMITTED )
23172323 .setTargetTimes (singletonList (topic ))
@@ -2331,10 +2337,17 @@ private ListOffsetsResponse createListOffsetResponse(short version) {
23312337 if (version >= 4 ) {
23322338 partition .setLeaderEpoch (27 );
23332339 }
2340+ ListOffsetsTopicResponse topicResponse = new ListOffsetsTopicResponse ();
2341+ // Version 12+ uses topic ID instead of topic name
2342+ if (version >= 12 ) {
2343+ topicResponse .setTopicId (Uuid .randomUuid ());
2344+ } else {
2345+ topicResponse .setName ("test" );
2346+ }
2347+ topicResponse .setPartitions (singletonList (partition ));
2348+
23342349 ListOffsetsResponseData data = new ListOffsetsResponseData ()
2335- .setTopics (singletonList (new ListOffsetsTopicResponse ()
2336- .setName ("test" )
2337- .setPartitions (singletonList (partition ))));
2350+ .setTopics (singletonList (topicResponse ));
23382351 return new ListOffsetsResponse (data );
23392352 } else {
23402353 throw new IllegalArgumentException ("Illegal ListOffsetResponse version " + version );
0 commit comments