junrao commented on code in PR #12570: URL: https://github.com/apache/kafka/pull/12570#discussion_r971047147
########## clients/src/test/java/org/apache/kafka/clients/producer/internals/RecordAccumulatorTest.java: ########## @@ -1129,31 +1129,34 @@ public void onCompletion(RecordMetadata metadata, Exception exception) { assertEquals(1, mockRandom.get()); // Produce large record, we should exceed "sticky" limit, but produce to this partition - // as we switch after the "sticky" limit is exceeded. The partition is switched after - // we produce. + // as we try to switch after the "sticky" limit is exceeded. The switch is disabled + // because of incomplete batch. byte[] largeValue = new byte[batchSize]; accum.append(topic, RecordMetadata.UNKNOWN_PARTITION, 0L, null, largeValue, Record.EMPTY_HEADERS, callbacks, maxBlockTimeMs, false, time.milliseconds(), cluster); assertEquals(partition1, partition.get()); - assertEquals(2, mockRandom.get()); + assertEquals(1, mockRandom.get()); - // Produce large record, we should switch to next partition. + // Produce large record, we switched to next partition by previous produce, but Review Comment: To be precise, the previous produce didn't switch to the next partition. The produce of this record forces the closing of the current batch, which cause the switch to the next partition. ########## clients/src/test/java/org/apache/kafka/clients/producer/internals/RecordAccumulatorTest.java: ########## @@ -1129,31 +1129,34 @@ public void onCompletion(RecordMetadata metadata, Exception exception) { assertEquals(1, mockRandom.get()); // Produce large record, we should exceed "sticky" limit, but produce to this partition - // as we switch after the "sticky" limit is exceeded. The partition is switched after - // we produce. + // as we try to switch after the "sticky" limit is exceeded. The switch is disabled + // because of incomplete batch. Review Comment: Thanks for the explanation, Artem. This makes sense to me 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. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org