test(producer): pin KafkaMessageSink error paths#192
Merged
Conversation
Closes a criticality-6 coverage gap: the existing tests only exercised happy paths. Add three tests that pin the error contract: - acceptPropagatesProducerExceptionAsRuntime: synchronous KafkaException from Producer.send must propagate (no silent log-and-swallow). The async-callback failure log is the only documented "swallow" path; sync throws are surfaced so upstream sink error handling can see them (§12). - acceptOnClosedProducerThrows: when the underlying producer is closed, Kafka throws IllegalStateException from send. The sink does not pre- check and does not swallow — it propagates so pipeline error handlers can react. - ofStaticFactoryWithNullKeyAccepted: the of(...) factory must produce a null-keyed ProducerRecord (Kafka allows null keys for round-robin / sticky partitioning).
Owner
Author
|
@copilot please review |
Copilot stopped work on behalf of
eschizoid due to an error
June 18, 2026 19:27
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #192 +/- ##
============================================
- Coverage 77.64% 77.60% -0.04%
+ Complexity 732 731 -1
============================================
Files 68 68
Lines 2800 2800
Branches 346 346
============================================
- Hits 2174 2173 -1
Misses 465 465
- Partials 161 162 +1 ☔ View full report in Codecov by Harness. |
Three Javadoc blocks referenced §12 — replaced with direct wording per the saved feedback (no spec/section refs in code comments). Also renamed `acceptPropagatesProducerExceptionAsRuntime` → `acceptPropagatesProducerExceptionUnwrapped`. The body asserts the original `KafkaException` propagates verbatim via `assertSame`, so "Unwrapped" matches the actual invariant; "AsRuntime" implied a rewrap that doesn't happen.
Owner
Author
|
@copilot please review |
Copilot stopped work on behalf of
eschizoid due to an error
June 18, 2026 19:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes a criticality-6 coverage gap on
KafkaMessageSink: the existing tests only covered happy paths. This PR adds three tests that pin the error-path contract — no production code changes.Invariants pinned
acceptPropagatesProducerExceptionAsRuntime— when the underlying KafkaProducer.send(record, callback)throws aKafkaExceptionsynchronously (serialization failure, authorization failure, buffer exhaustion withmax.block.ms=0, etc.), the sink must propagate the exception unwrapped, not catch-and-log. The async-callback failure path is the only "log and swallow" path the sink documents (per the class javadoc); synchronous throws are surfaced so upstream sink error handling (MessageProcessorRegistry.withSinkErrorHandling) can see them. Pins §12 (no-silent-failures doctrine).acceptOnClosedProducerThrows— per Kafka'sProducercontract, callingsend(...)on a closed producer throwsIllegalStateException("Cannot perform operation after producer has been closed"). The sink does not pre-check producer state and does not swallow this exception — it propagates so pipeline error handlers can route or fail loudly.ofStaticFactoryWithNullKeyAccepted— theKafkaMessageSink.of(producer, topic, valueMapper, tracer)factory produces a sink whose key path is null. Verifies the resultingProducerRecordhas anullkey (Kafka allows null keys; partition assignment falls back to the configured partitioner — round-robin / sticky for the default).Test plan
./gradlew :lib:kpipe-producer:test— 7 tests inKafkaMessageSinkTestall green