Skip to content

Conversation

@isaurab007
Copy link

@isaurab007 isaurab007 commented Sep 17, 2025

Add a null check for the lower level (de)serializer in ReleaseUnmanagedResources method during dispose flow of C# SerDe objects

Issue #, if available:

Right now, the Dispose methods in GlueSchemaRegistryDeserializer and GlueSchemaRegistrySerializer which are called during Finalize flow (triggered during garbage collection) are not thread safe.

However, it needs to be thread-safe as per recommendation. Ref: https://stackoverflow.com/questions/5306860/should-idisposable-dispose-be-made-safe-to-call-multiple-times

Description of changes:

We are handling a specific exception during the dispose flow (NullReferenceException) by checking if the lower-level serializer or deserializer object is null.

Before the null-check

image image

After the null-check

image

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@isaurab007 isaurab007 changed the title [DRAFT] Add a null check for the lower level (de)serializer in ReleaseUnmanagedResources method during dispose flow of C# SerDe objects [DRAFT] Add a null check for the lower level (de)serializer in ReleaseUnmanagedResources method during dispose flow of C# SerDe objects to avoid NPEs during disposal Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants