Skip to content

Commit

Permalink
Handle undefined fetcher in fold loop exception
Browse files Browse the repository at this point in the history
Prior to this commit, fold loop may crash if there
is an exception in message handler callback when
processing the last batch (i.e. when there is no
running fetcher for the next batch), kill_fetcher
function may crash on 'undefined' clause
  • Loading branch information
Zaiming Shi committed Nov 28, 2019
1 parent a8d243d commit 440f9d1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/brod_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ do_acc(Spawn, Fetcher, Offset, Acc, Fun, [Msg | Rest], End, Count) ->
erlang:raise(C, E, Stack)
end.

kill_fetcher(undefined) -> ok;
kill_fetcher({Pid, Mref}) ->
exit(Pid, kill),
receive
Expand Down

0 comments on commit 440f9d1

Please sign in to comment.