Skip to content

Commit

Permalink
Bugfix/handle empty stack (#4549)
Browse files Browse the repository at this point in the history
* Added a check for count before poping from stack.

* Fixed test to reflect actual expected exception.
  • Loading branch information
ujwalakhaire authored and Tom Laird-McConnell committed May 4, 2018
1 parent e1d8d02 commit 4d66269
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CSharp/Library/Microsoft.Bot.Builder/Fibers/Fiber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ async Task<IWait<C>> IFiberLoop<C>.PollAsync(C context, CancellationToken token)
}
catch (Exception error)
{
this.stack.Pop();
if (this.stack.Count != 0)
{
this.stack.Pop();
}

if (this.stack.Count == 0)
{
throw;
Expand Down
2 changes: 1 addition & 1 deletion CSharp/Tests/Microsoft.Bot.Builder.Tests/FiberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public async Task Fiber_OneCall_NeedDone()
}

[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
[ExpectedException(typeof(InvalidNeedException))]
public async Task Fiber_OneCall_ThenDone_Throws()
{
// arrange
Expand Down

0 comments on commit 4d66269

Please sign in to comment.