You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2026/09/11 02:30:28 UTC
(kafka) branch trunk updated: KAFKA-21053 Fix missing record context offset assertion (#23411)
This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 08f47056481 KAFKA-21053 Fix missing record context offset assertion (#23411)
08f47056481 is described below
commit 08f470564811d8dfb8f8f5c60a35996fc6ed01fa
Author: Andy Huang <16...@users.noreply.github.com>
AuthorDate: Fri Sep 11 10:30:20 2026 +0800
KAFKA-21053 Fix missing record context offset assertion (#23411)
The test `shouldThrowIllegalStateExceptionOnOffsetIfNoRecordContext`
still expects an exception, while `AbstractProcessorContext.offset()`
returns `-1L` when the record context is null. Its try/catch block
neither fails when no exception is thrown nor checks the returned value,
so it does not detect this mismatch.
The test was introduced in commit d95f22c12c (KAFKA-4646) in 2017, when
the implementation did throw `IllegalStateException`. In 2020, commit
69790a1463 (KAFKA-10535, #9361) changed the behavior to return `-1L`.
That commit updated the corresponding topic, partition, and timestamp
tests, but left the offset test unchanged.
This change renames the test to
`shouldReturnDummyOffsetIfNoRecordContext` and replaces the ineffective
try/catch with `assertEquals(-1L, context.offset())`. This verifies the
current behavior and follows the naming pattern of the neighboring
dummy-value tests.
Test plan: Run AbstractProcessorContextTest.
Reviewers: Ken Huang <s7...@gmail.com>, Chia-Ping Tsai
<ch...@gmail.com>
---
.../streams/processor/internals/AbstractProcessorContextTest.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/streams/src/test/java/org/apache/kafka/streams/processor/internals/AbstractProcessorContextTest.java b/streams/src/test/java/org/apache/kafka/streams/processor/internals/AbstractProcessorContextTest.java
index 96c46d688cf..5ab6e8c53f2 100644
--- a/streams/src/test/java/org/apache/kafka/streams/processor/internals/AbstractProcessorContextTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/processor/internals/AbstractProcessorContextTest.java
@@ -118,13 +118,9 @@ public class AbstractProcessorContextTest {
}
@Test
- public void shouldThrowIllegalStateExceptionOnOffsetIfNoRecordContext() {
+ public void shouldReturnDummyOffsetIfNoRecordContext() {
context.setRecordContext(null);
- try {
- context.offset();
- } catch (final IllegalStateException e) {
- // pass
- }
+ assertEquals(-1L, context.offset());
}
@Test