Skip to content

Commit 3fbc334

Browse files
committed
CSHARP-2296: Refactor IsRetryableWriteException to handle new base class of MongoNotPrimaryException and MongoNodeIsRecoveringException.
1 parent 49ab93b commit 3fbc334

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/MongoDB.Driver.Core/Core/Operations/RetryabilityHelper.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,19 @@ public static bool IsResumableChangeStreamException(Exception exception)
8383

8484
public static bool IsRetryableWriteException(Exception exception)
8585
{
86+
if (__retryableWriteExceptions.Contains(exception.GetType()))
87+
{
88+
return true;
89+
}
90+
8691
var commandException = exception as MongoCommandException;
8792
if (commandException != null)
8893
{
8994
var code = (ServerErrorCode)commandException.Code;
9095
return __retryableWriteErrorCodes.Contains(code);
9196
}
92-
else
93-
{
94-
return __retryableWriteExceptions.Contains(exception.GetType());
95-
}
97+
98+
return false;
9699
}
97100
}
98101
}

0 commit comments

Comments
 (0)