Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. In the one case where KafkaProducer is calling Callback.onCompletion directly, update the call to pass a placeholder value for metadata (in a manner consistent with the Javadoc) instead of a null value.
  2. Move the private nested InterceptorCallback class out of KafkaProducer, and create a dedicated public class for InterceptorCallback within 'clients.producer.internal' instead.
  3. Where KafkaProducer is passing InterceptorCallback to methods within 'clients.producer.internal' classes, update those methods to expect InterceptorCallback as input instead of Callback. This would make the conversion of metadata (from null to a placeholder value) that occurs within InterceptorCallback more explicit and would allow us to easily add unit tests to validate the behaviour of callbacks. For example, in this unit test we currently verify that when an exception occurs metadata will be null within the defined callback. As KafkaProducer is wrapping user defined callbacks inside of InterceptorCallback, user defined callbacks will never receive a null value and will always receive a placeholder value instead. By making the tested methods accept InterceptorCallback instead of Callback, we would then have to use InterceptorCallback within the tests, and those tests would verify the expected behaviour of Callback.onCompletion (namely that metadata should never be null, and instead return a placeholder value when exceptions occur).

A tested implementation of these changes can be found here.

Compatibility, Deprecation, and Migration Plan

...