Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit e4a5b87

Browse files
committed
Resolve new client when attempting to resolve Master client.
1 parent 8e4c2f5 commit e4a5b87

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/ServiceStack.Redis/RedisResolver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public virtual RedisClient CreateRedisClient(RedisEndpoint config, bool master)
9696

9797
firstEx ??= ex;
9898
ExecUtils.SleepBackOffMultiplier(++i);
99+
client?.Dispose();
100+
client = ClientFactory(config);
99101
}
100102
}
101103
throw new TimeoutException($"Could not resolve master instance within {config.RetryTimeout}ms RetryTimeout", firstEx);

tests/ServiceStack.Redis.Tests/RedisPasswordTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using NUnit.Framework;
1+
using System;
2+
using NUnit.Framework;
23

34
namespace ServiceStack.Redis.Tests
45
{
@@ -29,8 +30,9 @@ public void Passwords_are_not_leaked_in_exception_messages()
2930
Assert.Throws<RedisResponseException>(() => {
3031
try
3132
{
32-
var factory = new PooledRedisClientManager(password + "@" +
33-
TestConfig.SingleHost); // redis will throw when using password and it's not configured
33+
var connString = password + "@" + TestConfig.SingleHost + "?RetryTimeout=2000";
34+
// redis will throw when using password and it's not configured
35+
var factory = new PooledRedisClientManager(connString);
3436
using var redis = factory.GetClient();
3537
redis.SetValue("Foo", "Bar");
3638
}
@@ -39,6 +41,11 @@ public void Passwords_are_not_leaked_in_exception_messages()
3941
Assert.That(ex.Message, Is.Not.Contains(password));
4042
throw;
4143
}
44+
catch (TimeoutException tex)
45+
{
46+
Assert.That(tex.InnerException.Message, Is.Not.Contains(password));
47+
throw tex.InnerException;
48+
}
4249
},
4350
"Expected an exception after Redis AUTH command; try using a password that doesn't match.");
4451
}

0 commit comments

Comments
 (0)