Consume(CancellationToken cancellationToken) method can return a unchecked null ConsumeResult, throwing a NullReferenceException when the Consumer set up takes more than 100 ms
Create a new Consumer, no matter what IDeserializers are used, and consume a topic where the set up takes more that 100 ms
Checks if result is null in Confluent.Kafka.Consumer
557 public ConsumeResult<TKey, TValue> Consume(CancellationToken cancellationToken = default(CancellationToken))
...
563 if (result?.Message == null) { continue; }
To avoid an unchecked null return :
369 internal ConsumeResult<TKey, TValue> Consume(int millisecondsTimeout)
370 {
371 var msgPtr = kafkaHandle.ConsumerPoll((IntPtr)millisecondsTimeout);
372 if (msgPtr == IntPtr.Zero)
373 {
374 return null;
375 }
The previous version returns a non null ConsumeResult, then it was right to check the Message property:
return new ConsumeResult<TKey, TValue>
{
TopicPartitionOffset = new TopicPartitionOffset(null, Partition.Any, Offset.Invalid),
Message = null
};
thanks for the report @vicentegarciadiez - you're not the first to notice :-). will be fixed shortly.
should be resolved in -12.