Dispose method for KafkaStream object throws 'System.ObjectDisposedException: handle is destroyed'
See original GitHub issueDescription
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 :
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:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
1.2.0 released
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.