-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
BrokenRedisTests.TestWeAbortConnection test fails on the .NET Framework test configuration. The test expects a RedisConnectionException when connecting to a non-existent Redis endpoint, but instead receives an ObjectDisposedException.
Build
- TeamCity Build: Test .NET Framework (X64, VS 18.0, .NET SDK 10.0) #54
- Branch:
release/2026.0 - Configuration: Windows X64, VS 18.0, .NET Framework 4.8.1, .NET SDK 10.0
Error
Assert.Throws() Failure: Exception type was not an exact match
Expected: typeof(StackExchange.Redis.RedisConnectionException)
Actual: typeof(System.ObjectDisposedException)
---- System.ObjectDisposedException : Cannot access a disposed object.
Object name: 'Connection is being disposed'.
Stack trace: The ObjectDisposedException originates from RedisCachingBackend.InitAsync at Database.PingAsync() (RedisCachingBackend.cs:122), called from RedisCachingBackend.CreateAsync (RedisCachingBackend.cs:283).
Analysis
The test (Tests/Patterns/PostSharp.Patterns.Caching.Tests/Backends/Redis/BrokenRedisTests.cs) connects to 192.168.45.127:12345 (a non-existent endpoint) with AbortOnConnectFail = false and a very short timeout (10ms). It expects RedisCachingBackend.CreateAsync to throw RedisConnectionException.
However, with the current version of StackExchange.Redis and/or .NET SDK 10.0, the connection object is disposed before PingAsync is called, resulting in ObjectDisposedException instead of RedisConnectionException.
This is likely caused by a behavioral change in a newer version of StackExchange.Redis where the connection multiplexer disposal races with the ping attempt on a failed connection.
Possible Fix
Either:
- Update the test to also accept
ObjectDisposedException(if both exception types are valid) - Catch
ObjectDisposedExceptioninRedisCachingBackend.InitAsync/CreateAsyncand wrap it in a more meaningful exception