fix: accessing null object (cache) after shutdown#9678
Closed
egil wants to merge 1 commit intodotnet:mainfrom
Closed
fix: accessing null object (cache) after shutdown#9678egil wants to merge 1 commit intodotnet:mainfrom
egil wants to merge 1 commit intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a NullReferenceException that occurs when accessing the cache field after EventHubAdapterReceiver.Shutdown() has been called, particularly under high load conditions.
- Adds null-conditional operator when accessing
this.cacheinGetQueueMessagesAsync - Uses null-coalescing operator to handle potential null messageStreamPositions
- Includes minor formatting improvements with additional newlines
Comments suppressed due to low confidence (1)
src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterReceiver.cs:1
- The
GetCacheCursormethod still accessesthis.cachedirectly without null checking, which could cause the sameNullReferenceExceptionafter shutdown. Consider adding null safety here as well.
using System;
src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterReceiver.cs
Outdated
Show resolved
Hide resolved
src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterReceiver.cs
Outdated
Show resolved
Hide resolved
c96f0b3 to
aafbea6
Compare
shacal
reviewed
Sep 30, 2025
src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventHubAdapterReceiver.cs
Show resolved
Hide resolved
aafbea6 to
c4ba371
Compare
ReubenBond
approved these changes
Sep 30, 2025
c4ba371 to
c1afcd8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a
NullReferenceException, that I think happens inGetQueueMessagesAsyncwhen it tries to accesthis.cacheafterEventHubAdapterReceiver.Shutdown()has been called.This only happens under high load.
Here is the stack trace I have seen in production multiple times.
Microsoft Reviewers: Open in CodeFlow