Skip to content

Commit 24b0259

Browse files
authored
test(runtime): keep cancellation observers alive (#10790)
1 parent 26913b3 commit 24b0259

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

test/Orleans.Runtime.Tests/CancellationTests/CancellationTokenTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public async Task GrainTaskCancellation(int delay)
9797
finally
9898
{
9999
fixture.GrainFactory.DeleteObjectReference<ILongRunningTaskObserver>(observerReference);
100+
GC.KeepAlive(observer);
100101
}
101102
}
102103

@@ -142,6 +143,7 @@ await Task.WhenAll(grains.Select((grain, index) =>
142143
finally
143144
{
144145
fixture.GrainFactory.DeleteObjectReference<ILongRunningTaskObserver>(observerReference);
146+
GC.KeepAlive(observer);
145147
}
146148
}
147149

@@ -195,6 +197,7 @@ await Task.WhenAll(grainTasks.Select(task =>
195197
}
196198

197199
fixture.GrainFactory.DeleteObjectReference<ILongRunningTaskObserver>(observerReference);
200+
GC.KeepAlive(observer);
198201
}
199202
}
200203

@@ -476,6 +479,7 @@ public async Task InterleavingGrainTaskCancellation(int delay)
476479
finally
477480
{
478481
fixture.GrainFactory.DeleteObjectReference<ILongRunningTaskObserver>(observerReference);
482+
GC.KeepAlive(observer);
479483
}
480484
}
481485

test/Orleans.Runtime.Tests/CancellationTests/GrainCancellationTokenTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public async Task CancellationTokenCallbacksThrow_ExceptionShouldBePropagated()
184184
finally
185185
{
186186
fixture.GrainFactory.DeleteObjectReference<ILongRunningTaskObserver>(observerReference);
187+
GC.KeepAlive(observer);
187188
}
188189
}
189190

0 commit comments

Comments
 (0)