-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-9206: throw a KafkaException when encountering CORRUPT_MESSAGE #8111
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
Changes from 3 commits
efa1736
969295d
a58e1be
152323b
d8afd7e
8cd5c55
238eced
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3835,6 +3835,31 @@ public void testFetchCompletedBeforeHandlerAdded() { | |
| assertEquals(1, fetcher.sendFetches()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testCorruptMessageError() { | ||
| buildFetcher(); | ||
| assignFromUser(singleton(tp0)); | ||
| subscriptions.seek(tp0, 0); | ||
|
|
||
| assertEquals(1, fetcher.sendFetches()); | ||
| assertFalse(fetcher.hasCompletedFetches()); | ||
|
|
||
| // Prepare a response with the CORRUPT_MESSAGE error. | ||
| client.prepareResponse(fullFetchResponse( | ||
| tp0, | ||
| buildRecords(1L, 1, 1), | ||
| Errors.CORRUPT_MESSAGE, | ||
| 100L, 0)); | ||
| consumerClient.poll(time.timer(0)); | ||
| assertTrue(fetcher.hasCompletedFetches()); | ||
|
|
||
| // Trigger the exception. | ||
| assertThrows(KafkaException.class, () -> { | ||
| Map<TopicPartition, List<ConsumerRecord<byte[], byte[]>>> partitionRecords = | ||
| fetchedRecords(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: just calling fetchedRecords() should work here, or is compiler not liking it and forcing the return value assignment?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, made the change to discard the return value. |
||
| }); | ||
| } | ||
|
|
||
| private MockClient.RequestMatcher listOffsetRequestMatcher(final long timestamp) { | ||
| // matches any list offset request with the provided timestamp | ||
| return new MockClient.RequestMatcher() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're at it, could we add the fetch offset to the IllegalStateException message below and the
UNKNOWN_SERVER_ERRORlog message above?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.