Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
Conflicts:
	projects/client/RabbitMQ.Client/src/client/impl/Connection.cs
  • Loading branch information
michaelklishin committed Aug 2, 2016
2 parents a2feb24 + 6f82824 commit 3d355ec
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions projects/client/RabbitMQ.Client/src/client/impl/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,16 +1079,23 @@ protected void MaybeStopHeartbeatTimers()

private void MaybeDisposeTimer(ref Timer timer)
{
if (timer != null)
// capture the timer to reduce chance of a null ref exception
var captured = timer;
if (captured != null)
{
try
{
timer.Change(Timeout.Infinite, Timeout.Infinite);
timer.Dispose();
captured.Change(Timeout.Infinite, Timeout.Infinite);
captured.Dispose();
timer = null;
}
catch (ObjectDisposedException)
{
timer = null;
// we are shutting down, ignore
}
catch(NullReferenceException)
{
// this should be very rare but could occur from a race condition
}
}
}
Expand Down

0 comments on commit 3d355ec

Please sign in to comment.