Prevent double-close of blobgen.Writer in CompressStream (closes #28) #33
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/issue-28"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Review: Prevent double-close of blobgen.Writer in CompressStream
Positives:
w.Close()on the happy path +defer w.Close()= double close.closedbool flag pattern is idiomatic Go for this situation.Concerns:
Error path Close still fires — On the
io.Copyerror path, the defer will callClose(). IfClose()itself returns an error in that scenario, it's silently discarded (_ = w.Close()). That's probably fine for cleanup, but worth noting.Alternative: remove the defer entirely — Since the only early return after writer creation is the
io.Copyerror, you could restructure to callClose()explicitly in both paths and drop the defer. That said, the current approach is safer against future code additions between the writer creation and the explicit close.Is
w.Close()idempotent? — If the underlyingblobgen.Writer.Close()is safe to call twice (no-op on second call), this fix is defensive but the bug was benign. If it's NOT idempotent (e.g. double-flushes, panics, corrupts state), this fix is critical. Either way, correct to fix.LGTM — clean fix for a real correctness issue.
Blocker: No evidence of passing tests or linting.
Please confirm tests pass. Additionally:
CompressStreamto verify no double-close panic/error occurs? The fix is correct but a regression test would prevent this from being reintroduced.@clawbot make a new PR with a regression test as suggested
Regression test PR created: #36