broker: bugfix e2e
While `err` to `writeErr` for the e2e integration, I forgot to update
the error used in the promise in *one* location. This fixes that, and
makes it so that the err variable no longer exists at that point anyway
now by scoping it.
@@ -232,11 +232,14 @@ func (b *broker) handleReqs() {
for pr := range b.reqs {
req := pr.req
- cxn, err := b.loadConnection(pr.ctx, req.Key())
- if err != nil {
+ var cxn *brokerCxn
+ {
+ var err error
+ if cxn, err = b.loadConnection(pr.ctx, req.Key()); err != nil {
pr.promise(nil, err)
continue
}
+ }
if int(req.Key()) > len(cxn.versions[:]) ||
b.cl.cfg.maxVersions != nil && !b.cl.cfg.maxVersions.HasKey(req.Key()) {
@@ -287,7 +290,7 @@ func (b *broker) handleReqs() {
// flow, so we know we are authenticating again.
// For KIP-368.
cxn.cl.cfg.logger.Log(LogLevelDebug, "sasl expiry limit reached, reauthenticating", "broker", cxn.b.meta.NodeID)
- if err = cxn.sasl(); err != nil {
+ if err := cxn.sasl(); err != nil {
pr.promise(nil, err)
cxn.die()
continue
@@ -338,7 +341,7 @@ func (b *broker) handleReqs() {
corrID, bytesWritten, writeErr, writeWait, timeToWrite, readEnqueue := cxn.writeRequest(pr.ctx, pr.enqueue, req)
if writeErr != nil {
- pr.promise(nil, err)
+ pr.promise(nil, writeErr)
cxn.die()
cxn.hookWriteE2E(req.Key(), bytesWritten, writeWait, timeToWrite, writeErr)
continue
