Skip to content
Closed
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 @@ -1611,6 +1611,7 @@ public long position(TopicPartition partition, final Duration timeout) {
final long timeoutMs = timeout.toMillis();
acquireAndEnsureOpen();
try {
coordinator.poll(timeout.toMillis());
if (!this.subscriptions.isAssigned(partition))
throw new IllegalStateException("You can only check the position for partitions assigned to this consumer.");
Long offset = this.subscriptions.position(partition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ class PlaintextConsumerTest extends BaseConsumerTest {
consumers += consumer0

var commitCompleted = false
var committedPosition: Long = -1

val listener = new TestConsumerReassignmentListener {
override def onPartitionsRevoked(partitions: util.Collection[TopicPartition]): Unit = {
Expand All @@ -190,8 +189,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
// than session timeout and then try a commit. We should still be in the group,
// so the commit should succeed
Utils.sleep(1500)
committedPosition = consumer0.position(tp)
consumer0.commitSync(Map(tp -> new OffsetAndMetadata(committedPosition)).asJava)
consumer0.commitSync(Map(tp -> new OffsetAndMetadata(0)).asJava)
commitCompleted = true
}
super.onPartitionsRevoked(partitions)
Expand All @@ -207,7 +205,6 @@ class PlaintextConsumerTest extends BaseConsumerTest {
consumer0.subscribe(List("otherTopic").asJava, listener)
consumer0.poll(0)

assertEquals(0, committedPosition)
assertTrue(commitCompleted)
}

Expand Down