Skip to content

Update exception handling in SslStreamDisposeTest - #132748

Merged
rzikm merged 1 commit into
mainfrom
sslstreamdisposetest-fix
Aug 25, 2026
Merged

Update exception handling in SslStreamDisposeTest#132748
rzikm merged 1 commit into
mainfrom
sslstreamdisposetest-fix

Conversation

@rzikm

@rzikm rzikm commented Aug 25, 2026

Copy link
Copy Markdown
Member

Call to StreamBuffer.WriteAsync may be inlined, so we check for the presence of ConnectedStreams.* instead.

Example stacktrace of a failed test:

    System.Net.Security.Tests.SslStreamDisposeTest.Dispose_ParallelWithHandshake_ThrowsODE [FAIL]
      System.InvalidOperationException : Operation is not valid due to the current state of the object.
      Stack Trace:
        /_/src/libraries/Common/tests/System/IO/ConnectedStreams.cs(401,0): at System.IO.ConnectedStreams.BidirectionalStreamBufferStream.WriteAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.IO.cs(380,0): at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken)
        /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamDisposeTest.cs(150,0): at System.Net.Security.Tests.SslStreamDisposeTest.<Dispose_ParallelWithHandshake_ThrowsODE>g__ValidateExceptionAsync|3_1(Task task)
        /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamDisposeTest.cs(143,0): at System.Net.Security.Tests.SslStreamDisposeTest.<>c__DisplayClass3_0.<Dispose_ParallelWithHandshake_ThrowsODE>b__0(Int32 i, CancellationToken token)
        /_/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.ForEachAsync.cs(301,0): at System.Threading.Tasks.Parallel.<>c__53`1.<ForEachAsync>b__53_0(Object o)
        /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamDisposeTest.cs(115,0): at System.Net.Security.Tests.SslStreamDisposeTest.Dispose_ParallelWithHandshake_ThrowsODE()
        --- End of stack trace from previous location ---

Call to `StreamBuffer.WriteAsync` may be inlined, so we check for the presence of ConnectedStreams.* instead.
Copilot AI lite review requested due to automatic review settings August 25, 2026 13:51
@rzikm
rzikm requested a review from a team August 25, 2026 13:51
@rzikm
rzikm enabled auto-merge (squash) August 25, 2026 13:51
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the exception-filtering logic in SslStreamDisposeTest.Dispose_ParallelWithHandshake_ThrowsODE to better recognize a test-only InvalidOperationException originating from the ConnectedStreams test transport, making the test less sensitive to stack-trace changes from inlining.

Changes:

  • Adjusts the catch (InvalidOperationException) filter to look for System.IO.ConnectedStreams in the stack trace instead of System.IO.StreamBuffer.WriteAsync.
  • Keeps the behavior of treating that specific InvalidOperationException as an expected test-only outcome.

@wfurt wfurt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rzikm
rzikm merged commit 56c72f5 into main Aug 25, 2026
81 checks passed
@rzikm
rzikm deleted the sslstreamdisposetest-fix branch August 25, 2026 17:47
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants