From 0574d20f3d2a85ac83083bcbcb5d3a8fb61408d0 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Wed, 22 May 2024 23:51:42 -0600 Subject: [PATCH] eos example: avoid short-circuit logic Closes #729 --- examples/transactions/eos/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/transactions/eos/main.go b/examples/transactions/eos/main.go index 770a6519..6e726edb 100644 --- a/examples/transactions/eos/main.go +++ b/examples/transactions/eos/main.go @@ -75,7 +75,8 @@ func inputProducer() { for i := 0; i < 10; i++ { cl.Produce(ctx, kgo.StringRecord(msg+strconv.Itoa(i)), e.Promise()) } - commit := kgo.TransactionEndTry(doCommit && e.Err() == nil) + perr := e.Err() // always evaluate e.Err() to ensure we do not short circuit in the logic below (doCommit && ... would fail if doCommit is false!) + commit := kgo.TransactionEndTry(doCommit && perr == nil) switch err := cl.EndTransaction(ctx, commit); err { case nil: