Description
In PR #4188 as part of KAFKA-6180, a breaking change was accidentally introduced in the behaviour of Callbacks for the producer client.
Previously, whenever an exception was thrown when producing an event, the value for 'metadata' passed to the Callback.onCompletion method was always null. In PR #4188, in one part of the code where Callback.onCompletion is called, the behaviour was changed so that instead of passing a null value for metadata, a 'placeholder' value was provided instead (see here and here). This placeholder contained only topic and partition information, and with all other fields set to '-1'.
This change only impacted a subset of exceptions, so that in the case of ApiExceptions metadata would still be null (see here), but for all other exceptions the placeholder value would be used. The behaviour at the time of writing remains the same.
This issue was first reported in KAFKA-7412 when a user first noticed the difference between the documented behaviour of Callback.onCompletion and the implemented behaviour.
At the time it was assumed that the behaviour when errors occur was to always provide a placeholder metadata value to Callback.onCompletion, and the documentation was updated at that time to reflect this assumption in PR #5798. The documentation now states that when an exception occurs that the method will be called with an empty metadata value (see here). However, there is still one case where Callback.onCompletion is called with a null value for metadata (see here), so there is still a discrepancy between the documented behaviour and the implementation of Callback.onCompletion.
Attachments
Attachments
Issue Links
- duplicates
-
KAFKA-12841 NPE from the provided metadata in client callback in case of ApiException
-
- Resolved
-
- links to