Skip to content

Commit 4d66269

Browse files
ujwalakhaireTom Laird-McConnell
authored and
Tom Laird-McConnell
committed
Bugfix/handle empty stack (#4549)
* Added a check for count before poping from stack. * Fixed test to reflect actual expected exception.
1 parent e1d8d02 commit 4d66269

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CSharp/Library/Microsoft.Bot.Builder/Fibers/Fiber.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@ async Task<IWait<C>> IFiberLoop<C>.PollAsync(C context, CancellationToken token)
234234
}
235235
catch (Exception error)
236236
{
237-
this.stack.Pop();
237+
if (this.stack.Count != 0)
238+
{
239+
this.stack.Pop();
240+
}
241+
238242
if (this.stack.Count == 0)
239243
{
240244
throw;

CSharp/Tests/Microsoft.Bot.Builder.Tests/FiberTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public async Task Fiber_OneCall_NeedDone()
330330
}
331331

332332
[TestMethod]
333-
[ExpectedException(typeof(InvalidOperationException))]
333+
[ExpectedException(typeof(InvalidNeedException))]
334334
public async Task Fiber_OneCall_ThenDone_Throws()
335335
{
336336
// arrange

0 commit comments

Comments
 (0)