mirror of https://github.com/apache/kafka.git
KAFKA-5556; Fix IllegalStateException in KafkaConsumer.commitSync due to missing future completion check
This PR makes `commitOffsetsSync` method check whether future is completed after client's poll or not.
Author: umesh chaudhary <umesh9794@gmail.com>
Reviewers: Ismael Juma <ismael@juma.me.uk>, Jason Gustafson <jason@confluent.io>
Closes #3489 from umesh9794/KAFKA-5556
(cherry picked from commit e0099e1f58)
Signed-off-by: Jason Gustafson <jason@confluent.io>
This commit is contained in:
parent
2452201c57
commit
4b968afef2
|
|
@ -610,7 +610,7 @@ public final class ConsumerCoordinator extends AbstractCoordinator {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!future.isRetriable())
|
||||
if (future.failed() && !future.isRetriable())
|
||||
throw future.exception();
|
||||
|
||||
time.sleep(retryBackoffMs);
|
||||
|
|
|
|||
|
|
@ -1287,6 +1287,13 @@ public class ConsumerCoordinatorTest {
|
|||
assertTrue(mockOffsetCommitCallback.exception instanceof IllegalArgumentException);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommitOffsetSyncWithoutFutureGetsCompleted() {
|
||||
client.prepareResponse(groupCoordinatorResponse(node, Errors.NONE));
|
||||
coordinator.ensureCoordinatorReady();
|
||||
assertFalse(coordinator.commitOffsetsSync(Collections.singletonMap(t1p, new OffsetAndMetadata(100L)), 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshOffset() {
|
||||
client.prepareResponse(groupCoordinatorResponse(node, Errors.NONE));
|
||||
|
|
|
|||
Loading…
Reference in New Issue