Skip to content

Commit dc6310f

Browse files
committed
Catch ObjectDisposedException case
Prevent this exception from happening: ``` √ TestUnthrottledFloodPublishing [3m 5s] Test run in progress.................................................................. The active test run was aborted. Reason: Test host process crashed : Unhandled Exception: System.ObjectDisposedException: Cannot access a disposed object. at System.Threading.TimerQueueTimer.Change(UInt32 dueTime, UInt32 period) at RabbitMQ.Client.Framing.Impl.Connection.HeartbeatWriteTimerCallback(Object state) in /tmp/build/a94a8fe5/rabbitmq_dotnet_client/projects/client/RabbitMQ.Client/src/client/impl/Connection.cs:line 1140 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.TimerQueueTimer.CallCallback() at System.Threading.TimerQueueTimer.Fire() at System.Threading.TimerQueue.FireNextTimers() ```
1 parent 2605d55 commit dc6310f

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

projects/client/RabbitMQ.Client/src/client/impl/Connection.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ public void HeartbeatWriteTimerCallback(object state)
901901
if (!_closed)
902902
{
903903
WriteFrame(_heartbeatFrame);
904+
_heartbeatWriteTimer?.Change((int)_heartbeatTimeSpan.TotalMilliseconds, Timeout.Infinite);
904905
}
905906
}
906907
catch (ObjectDisposedException)
@@ -913,11 +914,6 @@ public void HeartbeatWriteTimerCallback(object state)
913914
// ignore, let the read callback detect
914915
// peer unavailability. See rabbitmq/rabbitmq-dotnet-client#638 for details.
915916
}
916-
917-
if (_closed == false)
918-
{
919-
_heartbeatWriteTimer?.Change((int)_heartbeatTimeSpan.TotalMilliseconds, Timeout.Infinite);
920-
}
921917
}
922918

923919
void MaybeStopHeartbeatTimers()

0 commit comments

Comments
 (0)