LGouellec / kafka-streams-dotnet

.NET Stream Processing Library for Apache Kafka 🚀
https://lgouellec.github.io/kafka-streams-dotnet/
MIT License
455 stars 74 forks source link

NullReferenceException when restoring topology with stream-stream join #105

Closed terry-yip closed 2 years ago

terry-yip commented 2 years ago

Description

NullReferenceException when restoring topology with stream-stream join.

using Microsoft.Extensions.Logging;
using Streamiz.Kafka.Net;
using Streamiz.Kafka.Net.SerDes;
using Streamiz.Kafka.Net.Stream;

var config = new StreamConfig<StringSerDes, StringSerDes>
{
    ApplicationId = "reproduce-nullreferenceexception", 
    BootstrapServers = "127.0.0.1:9092",
    AutoOffsetReset = Confluent.Kafka.AutoOffsetReset.Earliest,
    Logger = LoggerFactory.Create(builder =>
    {
        builder.SetMinimumLevel(LogLevel.Debug);
        builder.AddConsole();
    })
};

StreamBuilder builder = new StreamBuilder();

var stream = builder.Stream<string, string>("topic1").SelectKey((k, v) => "key");

builder
    .Stream<string, string>("topic2")
    .SelectKey((k, v) => "key")
    .Join(
        stream,
        (s, v) => $"{s}-{v}",
        JoinWindowOptions.Of(TimeSpan.FromSeconds(10)))
    .To("output-join");

Topology t = builder.Build();

var kafkaStream = new KafkaStream(t, config);
await kafkaStream.StartAsync();

Console.ReadLine();

How to reproduce

  1. Make sure kafka is running, Messages exist in Topic1 and Topic2
  2. Run the test application provided above, make sure at least 1 message in the streams are consumed.
  3. Stop the test application, make sure the JOIN state topics are generated in kafka.
  4. Re-run the test application, the exception will occur during the restore phase

Checklist

Please provide the following information:

terry-yip commented 2 years ago

Created PR to fix this issue for your reference https://github.com/LGouellec/kafka-streams-dotnet/pull/106

LGouellec commented 2 years ago

PR merged. Hot fix : 1.2.2 released.

Great works ! thanks