Skip to content

Commit 58a113d

Browse files
committed
* Don't log an expected exception.
1 parent ca9a078 commit 58a113d

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

RabbitMQ.AMQP.Client/Impl/AbstractLifeCycle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected void ThrowIfClosed()
4747
case State.Closing:
4848
throw new AmqpNotOpenException("Resource is closing");
4949
case State.Reconnecting:
50-
throw new AmqpNotOpenException("Resource is Reconnecting");
50+
throw new AmqpNotOpenException("Resource is reconnecting");
5151
case State.Open:
5252
break;
5353
default:

RabbitMQ.AMQP.Client/Impl/AmqpEnvironment.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ public async Task<IConnection> CreateConnectionAsync(IConnectionSettings connect
4646
return c;
4747
}
4848

49-
public async Task<IConnection> CreateConnectionAsync()
49+
public Task<IConnection> CreateConnectionAsync()
5050
{
51-
if (ConnectionSettings != null)
51+
if (ConnectionSettings is null)
5252
{
53-
return await CreateConnectionAsync(ConnectionSettings).ConfigureAwait(false);
53+
throw new ConnectionException("Connection settings are not set");
5454
}
5555

56-
throw new ConnectionException("Connection settings are not set");
56+
return CreateConnectionAsync(ConnectionSettings);
5757
}
5858

5959
public ReadOnlyCollection<IConnection> GetConnections() =>

Tests/Rpc/RecoveryRPCTests.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public async Task RpcServerAndClientShouldRecoverAfterKillConnection()
3333
int messagesReceived = 0;
3434
IRpcServer rpcServer = await connection.RpcServerBuilder()
3535
.RequestQueue(rpcRequestQueueName)
36-
.Handler(async (context, message) =>
36+
.Handler((context, message) =>
3737
{
3838
Interlocked.Increment(ref messagesReceived);
3939
var reply = context.Message("pong");
40-
return await Task.FromResult(reply);
40+
return Task.FromResult(reply);
4141
})
4242
.BuildAsync();
4343

@@ -62,9 +62,13 @@ public async Task RpcServerAndClientShouldRecoverAfterKillConnection()
6262
messagesConfirmed++;
6363
Assert.Equal("pong", response.Body());
6464
}
65+
catch (AmqpNotOpenException)
66+
{
67+
await Task.Delay(700);
68+
}
6569
catch (Exception e)
6670
{
67-
_testOutputHelper.WriteLine($"Error sending message: {e.Message}");
71+
_testOutputHelper.WriteLine($"[ERROR] unexpected exception while sending message: {e.Message}");
6872
await Task.Delay(700);
6973
}
7074

0 commit comments

Comments
 (0)