Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static class EndpointResolverExtensions
public static T SelectOne<T>(this IEndpointResolver resolver, Func<AmqpTcpEndpoint, T> selector)
{
var t = default(T);
Exception exception = null;
var exceptions = new List<Exception>();
foreach(var ep in resolver.All())
{
try
Expand All @@ -62,13 +62,13 @@ public static T SelectOne<T>(this IEndpointResolver resolver, Func<AmqpTcpEndpoi
}
catch (Exception e)
{
exception = e;
exceptions.Add(e);
}
}

if(Object.Equals(t, default(T)) && exception != null)
if(Object.Equals(t, default(T)) && exceptions.Count > 0)
{
throw exception;
throw new AggregateException(exceptions);
}

return t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ namespace RabbitMQ.Client.Exceptions
///ConnectionFactory.CreateConnection attempt.</summary>
public class BrokerUnreachableException : IOException
{
///<summary>Construct a BrokerUnreachableException. The inner exception is associated
///with only one connection attempt.</summary>
///<summary>Construct a BrokerUnreachableException. The inner exception is
///an AggregateException holding the errors from multiple connection attempts.</summary>
public BrokerUnreachableException(Exception Inner)
: base("None of the specified endpoints were reachable", Inner)
{
Expand Down
11 changes: 0 additions & 11 deletions projects/client/RabbitMQ.Client/src/client/impl/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,6 @@ public class Connection : IConnection
.InformationalVersion;
#endif

#if CORECLR
private static string version = typeof(Connection).GetTypeInfo().Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
#else
private static string version = typeof(Connection).Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
#endif


// true if we haven't finished connection negotiation.
// In this state socket exceptions are treated as fatal connection
// errors, otherwise as read timeouts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public void SelectOneShouldReturnDefaultWhenThereAreNoEndpoints()
public void SelectOneShouldRaiseThrownExceptionWhenThereAreOnlyInaccessibleEndpoints()
{
var ep = new TestEndpointResolver(new List<AmqpTcpEndpoint> { new AmqpTcpEndpoint()});
Assert.Throws<TestEndpointException>(() => ep.SelectOne<AmqpTcpEndpoint>((x) => { throw new TestEndpointException("bananas"); }));
var thrown = Assert.Throws<AggregateException>(() => ep.SelectOne<AmqpTcpEndpoint>((x) => { throw new TestEndpointException("bananas"); }));
Assert.That(thrown.InnerExceptions, Has.Exactly(1).TypeOf<TestEndpointException>());
}

[Test]
Expand Down