Skip to content

Commit

Permalink
Fix #813
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
  • Loading branch information
slinkydeveloper committed Apr 16, 2021
1 parent 4c7f76d commit 84baddd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private int blockIndex(long val) {
}

private void checkAcksArraySize(int blockIndex) {
if (this.uncommitted.length < blockIndex) {
if (blockIndex > this.uncommitted.length - 1) {
// Let's make sure we create enough room for more unordered records
this.uncommitted = Arrays.copyOf(this.uncommitted, (blockIndex + 1) * 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ public void shouldCommitAfterSendingEventsOrderedOnTheSamePartition() {
.containsEntry(new TopicPartition("aaa", 0), 10L);
}

@Test
public void shouldNotCommitAndNotGoOutOfBounds() {
assertThatOffsetCommitted(List.of(new TopicPartition("aaa", 0)), offsetStrategy -> {
offsetStrategy.recordReceived(record("aaa", 0, 0));
offsetStrategy.successfullySentToSubscriber(record("aaa", 0, 64));
offsetStrategy.successfullySentToSubscriber(record("aaa", 0, 128));
})
.isEmpty();
}

@Test
public void shouldCommitAfterSendingEventsOrderedOnTheSamePartitionWithInducedFailure() {
assertThatOffsetCommittedWithFailures(List.of(new TopicPartition("aaa", 0)), (offsetStrategy, failureFlag) -> {
Expand Down

0 comments on commit 84baddd

Please sign in to comment.