Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out of bounds in unordered offset manager #814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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