question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dispose method for KafkaStream object throws 'System.ObjectDisposedException: handle is destroyed'

See original GitHub issue

Description

Hello, I have created simple console application to test GlobalTable + InMemory state store and everything works fine untill we close application. As recommended I do a call to KafkaStream.Dispose() and it throws an error :

image

Can you please help me with that ? What could be the cause of this issue ?

How to reproduce

Create .net 5.0 console application with Streamiz.Kafka.Net v1.1.5 I removed reading from state store because it doesn’t affect this issue, the minimal code to reproduce it below.

Configure and start:

            var config = new StreamConfig<StringSerDes, StringSerDes>();
            config.ApplicationId = "test-app-123";
            config.BootstrapServers = "localhost:9092";
            config.AutoOffsetReset = AutoOffsetReset.Earliest;

            StreamBuilder builder = new StreamBuilder();
            builder.GlobalTable("dima-test", InMemory<string, string>.As("dima-test-store"));

            Topology t = builder.Build();
            KafkaStream stream = new KafkaStream(t, config);
            await stream.StartAsync();

            await Task.Delay(2000);

            stream.Dispose();

Checklist

Please provide the following information:

  • A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
  • A code snippet with your topology builder (ex: builder.Stream<string, string>(“topic”).to(“an-another-topic”)😉
  • Streamiz.Kafka.Net nuget version. - v1.1.5
  • Apache Kafka version. - v1.6.2 (which is referenced from Streamiz library)
  • Client configuration.
  • Operating system. - Windows 10
  • Provide logs (with in debug mode (log4net and StreamConfig.Debug) as necessary in configuration).
  • Critical issue. - no

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
LGouelleccommented, Jan 31, 2022

1.2.0 released

1reaction
LGouelleccommented, Jul 21, 2021

Description

Hello, I have created simple console application to test GlobalTable + InMemory state store and everything works fine untill we close application. As recommended I do a call to KafkaStream.Dispose() and it throws an error :

image

Can you please help me with that ? What could be the cause of this issue ?

How to reproduce

Create .net 5.0 console application with Streamiz.Kafka.Net v1.1.5 I removed reading from state store because it doesn’t affect this issue, the minimal code to reproduce it below.

Configure and start:

            var config = new StreamConfig<StringSerDes, StringSerDes>();
            config.ApplicationId = "test-app-123";
            config.BootstrapServers = "localhost:9092";
            config.AutoOffsetReset = AutoOffsetReset.Earliest;

            StreamBuilder builder = new StreamBuilder();
            builder.GlobalTable("dima-test", InMemory<string, string>.As("dima-test-store"));

            Topology t = builder.Build();
            KafkaStream stream = new KafkaStream(t, config);
            await stream.StartAsync();

            await Task.Delay(2000);

            stream.Dispose();

Checklist

Please provide the following information:

  • A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
  • A code snippet with your topology builder (ex: builder.Stream<string, string>(“topic”).to(“an-another-topic”)😉
  • Streamiz.Kafka.Net nuget version. - v1.1.5
  • Apache Kafka version. - v1.6.2 (which is referenced from Streamiz library)
  • Client configuration.
  • Operating system. - Windows 10
  • Provide logs (with in debug mode (log4net and StreamConfig.Debug) as necessary in configuration).
  • Critical issue. - no

I reproduced your fix, and in fact, sometimes an error is logged with ObjectDisposedException raised. It’s not a fatal error because it’s catch.

But I fixed this issue in my branch fix/84, will release in next release 1.2.0 in some weeks I hope.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.ObjectDisposedException: handle is destroyed
1 Answer. in my case this exception was thrown in . Net Library Confluent Kafka. If you are also using this library, please...
Read more >
ObjectDisposedException on consumer finalization #577
If an object is finalized (is garbage collected without being disposed), the consumer object is being cleaned up before the librdkafka handles.
Read more >
ObjectDisposedException Class (System)
An ObjectDisposedException is thrown when you try to access a member of an object that implements the IDisposable interface or IAsyncDisposable interface, and ......
Read more >
Handling uncaught exceptions using Confluent
In this tutorial, learn how to handle uncaught exceptions using Confluent, with step-by-step instructions and examples.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found