Skip to content

Commit 2420e1e

Browse files
authored
CSHARP-5329: Fix RetryableWrites_testCase__insertOne-serverErrors.json_RetryableWriteError_label_is_not_added_based_on_writeConcernError_in_pre-4.4_mongos_response test (#1498)
1 parent 5480816 commit 2420e1e

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
lines changed

src/MongoDB.Driver/Core/MongoCommandException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected MongoCommandException(SerializationInfo info, StreamingContext context
9090
/// <value>
9191
/// The error code.
9292
/// </value>
93-
public virtual int Code
93+
public int Code
9494
{
9595
get { return _result.GetValue("code", -1).ToInt32(); }
9696
}

src/MongoDB.Driver/Core/MongoWriteConcernException.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,6 @@ public MongoWriteConcernException(SerializationInfo info, StreamingContext conte
9191
AddErrorLabelsFromWriteConcernResult(this, _writeConcernResult);
9292
}
9393

94-
/// <inheritdoc/>
95-
public override int Code
96-
{
97-
get
98-
{
99-
if (WriteConcernResult.Response["writeConcernError"].AsBsonDocument.TryGetValue("code", out var code))
100-
{
101-
return code.AsInt32;
102-
}
103-
104-
return base.Code;
105-
}
106-
}
107-
10894
// properties
10995
/// <summary>
11096
/// Gets the mapped write concern result exception.

tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedErrorMatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private void AssertWriteConcernErrors(Exception actualException, BsonArray expec
183183
clientBulkWriteException.WriteConcernErrors.Select(
184184
e => new BsonDocument
185185
{
186-
{ "code", e.Code },
186+
{ "code", ((MongoCommandException)e.MappedWriteConcernResultException).Code },
187187
{ "message", e.Message }
188188
}));
189189

0 commit comments

Comments
 (0)