andyhuangdev opened a new pull request, #23411: URL: https://github.com/apache/kafka/pull/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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
