Commit 4cbe83b
[FaultInjection] FaultInjection: Fixes critical bugs for release 2 (#5675)
## Summary
This PR addresses critical bug fixes in the FaultInjection library
identified during the pre-release analysis for Release 2.
### Changes
**1. Thread-safety fix in
`FaultInjectionApplicationContext.AddRuleExecution()` (#5653)**
- The `AddRuleExecution()` method was using `TryAdd` + direct
`List<T>.Add()` on values stored in `ConcurrentDictionary`, which is not
thread-safe. Replaced with `AddOrUpdate()` with `lock` synchronization
on the list instances.
**2. SendDelay validation in
`FaultInjectionServerErrorResultBuilder.Build()` (#5654)**
- `Build()` validated that a delay was set for `ResponseDelay` and
`ConnectionDelay` error types, but not for `SendDelay`. Users could
create a `SendDelay` rule without specifying a delay (defaulting to
`TimeSpan.Zero`). Added `SendDelay` to the validation check.
**3. Incorrect `OutputType` in `FaultInjection.csproj` (#5655)**
- The csproj had `<OutputType>Exe</OutputType>` and
`<TargetType>library</TargetType>` which is contradictory. Removed both
lines since the default for SDK-style projects is `Library`.
**4. Null validation in `FaultInjector` constructor (#5656)**
- The constructor accepted `null` for the `rules` parameter without
validation, leading to a deferred `NullReferenceException`. Added an
`ArgumentNullException` guard.
### Testing
- Build verified locally with `dotnet build`
- All changes are minimal and surgical
Parent tracking issue: #5652
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>1 parent d8c473f commit 4cbe83b
4 files changed
Lines changed: 29 additions & 11 deletions
File tree
- Microsoft.Azure.Cosmos/FaultInjection/src
- implementation
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | | - | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
Lines changed: 22 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
33 | 40 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
38 | 52 | | |
39 | 53 | | |
40 | 54 | | |
| |||
0 commit comments