-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ODataNotificationWriter and ODataNotificationStream wrapper classes should not dispose the passed TextWriter and Stream respectively #2110
Conversation
…hould not dispose the passed TextWriter and Stream respectively
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
@@ -32,7 +32,7 @@ public void NotificationStreamDisposeShouldInvokeStreamDisposed(bool synchronous | |||
// We care about the notification stream being disposed | |||
// We don't care about the stream passed to the notification stream | |||
using (var notificationStream = new ODataNotificationStream( | |||
new MemoryStream(), | |||
this.stream, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change necessary? Is this.stream
used in the test? Do you make a check to verify that it was not disposed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please observe that I'm verifying that StreamDisposed
or StreamDiposedAsync
are invoked by reading the content of the stream they wrote to when they were invoked. In the previous case, StreamDisposed
/StreamDiposedAsync
were writing to a stream entirely different to the one passed to ODataNotificationStream
constructor. Since ODataNotifictionStream
is not disposing the stream after the change, I was able to make StreamDisposed
/StreamDiposedAsync
write to the same stream passed to the constructor with the assurance that it'll still be available for the the helper ReadStreamContents
/ReadStreamContentsAsync
methods to read from. That is why I noted in the PR description that the change I made to the tests is the confirmation needed to verify that the stream is not disposed
Description
ODataNotificationWriter
andODataNotificationStream
wrapper classes should not dispose the passedTextWriter
andStream
respectively.Reference to merged PRs 2079 and 2080 implementing support for asynchronous invocation of
IODataStreamListener.StreamDisposedAsync
fromODataNotificationWriter
andODataNotificationStream
wrapper classes, a line was added such that the passedTextWriter
andStream
respectively are disposed when theDispose
method is called.This can cause a problem if the owner of
TextWriter
orStream
chose to use it after - though that does not happen currently. This pull request addresses that loop hole, leaving the owner to do the disposing.NOTE: Confirmation of the fix is in the change made to the tests where the test class is able to read from the stream even after the
ODataNotificationWriter
orODataNotificationStream
instance is disposed.Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.