Skip to content

Commit

Permalink
Fix: Fix missing store of computed value in TypedValue (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoog authored Oct 27, 2023
1 parent d752c34 commit 620bd74
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kvstore/typedvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ func (t *TypedValue[V]) Compute(computeFunc func(currentValue V, exists bool) (n
}

return newValue, ierrors.Wrap(err, "failed to compute new value")
} else if newValueBytes, newValueBytesErr := t.vToBytes(newValue); err != nil {
return currentValue, ierrors.Wrap(newValueBytesErr, "failed to encode new value")
} else if err = t.kv.Set(t.keyBytes, newValueBytes); err != nil {
return currentValue, ierrors.Wrap(err, "failed to store new value in KV store")
}

t.valueCached = &newValue
Expand All @@ -123,7 +127,7 @@ func (t *TypedValue[V]) Set(value V) error {
if valueBytes, err := t.vToBytes(value); err != nil {
return ierrors.Wrap(err, "failed to encode value")
} else if err = t.kv.Set(t.keyBytes, valueBytes); err != nil {
return ierrors.Wrap(err, "failed to store in KV store")
return ierrors.Wrap(err, "failed to store value in KV store")
}

t.valueCached = &value
Expand Down

0 comments on commit 620bd74

Please sign in to comment.