Skip to content

Commit 9c133b6

Browse files
authored
Merge development branch for v5.6.0
2 parents 24165be + 3f76b98 commit 9c133b6

81 files changed

Lines changed: 2334 additions & 232 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ TestResults
1313
*.user
1414
*.sln.docstates
1515
.vs/
16+
.vscode/
1617

1718
# Build results
1819
[Dd]ebug/

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 5.6.0
2+
- Add ability to handle inner exceptions natively: .HandleInner<TEx>()
3+
- Allow WaitAndRetry policies to calculate wait based on the handled fault
4+
- Add the ability to access the policies within an IPolicyWrap
5+
- Allow PolicyWrap to configure policies expressed as interfaces
6+
- Bug fix: set context keys for generic execute methods with PolicyWrap
7+
- Bug fix: generic TResult method with non-generic fallback policy
8+
- Performance improvements
9+
- Multiple build speed improvements
10+
111
## 5.5.0
212
- Bug fix: non-generic CachePolicy with PolicyWrap
313
- Add Cache interfaces

GitVersionConfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
next-version: 5.5.0
1+
next-version: 5.6.0

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ You can install the Strongly Named version via:
2727
Install-Package Polly.Net40Async-Signed
2828

2929

30-
3130
# Resilience policies
3231

3332
Polly offers multiple resilience policies:
@@ -52,8 +51,6 @@ Fault-handling policies handle specific exceptions thrown by, or results returne
5251

5352
### (for fault-handling policies: Retry family, CircuitBreaker family and Fallback)
5453

55-
56-
5754
```csharp
5855
// Single exception type
5956
Policy
@@ -72,6 +69,11 @@ Policy
7269
Policy
7370
.Handle<SqlException>(ex => ex.Number == 1205)
7471
.Or<ArgumentException>(ex => ex.ParamName == "example")
72+
73+
// Inner exceptions of ordinary exceptions or AggregateException, with or without conditions
74+
Policy
75+
.HandleInner<HttpResponseException>()
76+
.OrInner<OperationCanceledException>(ex => ex.CancellationToken == myToken)
7577
```
7678

7779
## Step 1b: (optionally) Specify return results you want to handle
@@ -938,6 +940,13 @@ For details of changes by release see the [change log](https://github.com/App-vN
938940
* [@jiimaho](https://github.com/jiimaho) and [@Extremo75](https://github.com/ExtRemo75) - Provide public factory methods for PolicyResult, to support testing.
939941
* [@Extremo75](https://github.com/ExtRemo75) - Allow fallback delegates to take handled fault as input parameter.
940942
* [@reisenberger](https://github.com/reisenberger) and [@seanfarrow](https://github.com/SeanFarrow) - Add CachePolicy, with interfaces for pluggable cache providers and serializers.
943+
* Thanks to the awesome devs at [@tretton37](https://github.com/tretton37) who delivered the following as part of a one-day in-company hackathon led by [@reisenberger](https://github.com/reisenberger), sponsored by [@tretton37](https://github.com/tretton37) and convened by [@thecodejunkie](https://github.com/thecodejunkie)
944+
* [@matst80](https://github.com/matst80) - Allow WaitAndRetry to take handled fault as an input to the sleepDurationProvider, allowing WaitAndRetry to take account of systems which specify a duration to wait as part of a fault response; eg Azure CosmosDB may specify this in `x-ms-retry-after-ms` headers or in a property to an exception thrown by the Azure CosmosDB SDK.
945+
* [@MartinSStewart](https://github.com/martinsstewart) - Add GetPolicies() extension methods to IPolicyWrap.
946+
* [@jbergens37](https://github.com/jbergens37) - Parallelize test running where possible, to improve overall build speed.
947+
* [@reisenberger](https://github.com/reisenberger) - Add new .HandleInner<TException>(...) syntax for handling inner exceptions natively.
948+
* [@rjongeneelen](https://github.com/rjongeneelen) and [@reisenberger](https://github.com/reisenberger) - Allow PolicyWrap configuration to configure policies via interfaces.
949+
* [@reisenberger](https://github.com/reisenberger) - Performance improvements.
941950
942951
# Sample Projects
943952

src/Polly.Net40Async.Specs/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
using Xunit;
33

44
[assembly: AssemblyTitle("Polly.Net40Async.Specs")]
5-
[assembly: CollectionBehavior(DisableTestParallelization = true)]
5+
[assembly: CollectionBehavior(DisableTestParallelization = false)]

src/Polly.Net40Async.nuspec

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@
1313
<tags>Exception Handling Resilience Transient Fault Policy Circuit Breaker CircuitBreaker Retry Wait Cache Cache-aside Bulkhead Fallback Timeout Throttle Parallelization</tags>
1414
<copyright>Copyright © 2017, App vNext</copyright>
1515
<releaseNotes>
16-
v5.0 is a major release with significant new resilience policies: Timeout; Bulkhead Isolation; Fallback; Cache; and PolicyWrap. See release notes back to v5.0.0 for full details. v5.0.5 includes important circuit-breaker fixes.
16+
v5.0 is a major release with significant new resilience policies: Timeout; Bulkhead Isolation; Fallback; Cache; and PolicyWrap. See release notes back to v5.0.0 for full details.
17+
18+
5.6.0
19+
---------------------
20+
- Add ability to handle inner exceptions natively: .HandleInner&lt;TEx&gt;()
21+
- Allow WaitAndRetry policies to calculate wait based on the handled fault
22+
- Add the ability to access the policies within an IPolicyWrap
23+
- Allow PolicyWrap to take interfaces as parameters
24+
- Bug fix: set context keys for generic execute method with PolicyWrap
25+
- Bug fix: generic TResult method with non-generic fallback policy
26+
- Performance improvements
1727

1828
5.5.0
1929
---------------------

src/Polly.Net45.Specs/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
using Xunit;
33

44
[assembly: AssemblyTitle("Polly.Net45.Specs")]
5-
[assembly: CollectionBehavior(DisableTestParallelization = true)]
5+
[assembly: CollectionBehavior(DisableTestParallelization = false)]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)]
1+
[assembly: Xunit.CollectionBehavior(DisableTestParallelization = false)]

src/Polly.NetStandard11/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Runtime.CompilerServices;
44

55
[assembly: AssemblyTitle("Polly")]
6-
[assembly: AssemblyVersion("5.5.0.0")]
6+
[assembly: AssemblyVersion("5.6.0.0")]
77
[assembly: CLSCompliant(true)]
88

99
[assembly: InternalsVisibleTo("Polly.NetStandard11.Specs")]

src/Polly.Shared/CircuitBreaker/CircuitBreakerEngine.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Runtime.ExceptionServices;
45
using System.Threading;
56

7+
#if NET40
8+
using ExceptionDispatchInfo = Polly.Utilities.ExceptionDispatchInfo;
9+
#endif
10+
611
namespace Polly.CircuitBreaker
712
{
813
internal partial class CircuitBreakerEngine
@@ -36,13 +41,20 @@ internal static TResult Implementation<TResult>(
3641
}
3742
catch (Exception ex)
3843
{
39-
if (!shouldHandleExceptionPredicates.Any(predicate => predicate(ex)))
44+
Exception handledException = shouldHandleExceptionPredicates
45+
.Select(predicate => predicate(ex))
46+
.FirstOrDefault(e => e != null);
47+
if (handledException == null)
4048
{
4149
throw;
4250
}
4351

44-
breakerController.OnActionFailure(new DelegateResult<TResult>(ex), context);
52+
breakerController.OnActionFailure(new DelegateResult<TResult>(handledException), context);
4553

54+
if (handledException != ex)
55+
{
56+
ExceptionDispatchInfo.Capture(handledException).Throw();
57+
}
4658
throw;
4759
}
4860
}

0 commit comments

Comments
 (0)