fallintoplace commented on code in PR #1047:
URL: https://github.com/apache/arrow-go/pull/1047#discussion_r3722117918


##########
arrow/ipc/writer.go:
##########
@@ -148,24 +165,38 @@ func (w *Writer) Close() error {
        }
 
        err := w.pw.Close()
+       w.pw = nil
+       w.releaseDictionaries()
        if err != nil {
-               return fmt.Errorf("arrow/ipc: could not close payload writer: 
%w", err)
+               return w.fail(fmt.Errorf("arrow/ipc: could not close payload 
writer: %w", err))
        }
-       w.pw = nil
 
+       return nil
+}
+
+func (w *Writer) releaseDictionaries() {
        for _, d := range w.lastWrittenDicts {
                d.Release()
        }
+       w.lastWrittenDicts = nil
+}
 
-       return nil
+func (w *Writer) fail(err error) error {
+       if w.err == nil {
+               w.err = err
+       }
+       return w.err

Review Comment:
   I kept first-error-wins intentionally. Once w.err is set, Write and Close 
return immediately, so later operations are not attempted. Returning the 
original error also keeps the terminal error stable. I can revisit this if we 
expect cleanup to produce another error that should be preserved.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to