ARROW-11681: [Rust] Don't unwrap in IPC writers
A common reason a writer would be dropping without finishing is because
the underlying stream returned an earlier error. In that case, the
destructor will probably also encounter an error, resulting in a panic.
Instead just ignore the result from finish, mirroring the behavior of
the standard library's BufWriter.
Closes #9520 from sfackler/ipc-panic
Authored-by: Steven Fackler <sfackler@gmail.com>
Signed-off-by: Andrew Lamb <andrew@nerdnetworks.org>
diff --git a/rust/arrow/src/ipc/writer.rs b/rust/arrow/src/ipc/writer.rs
index 688829a..bc5e4cc 100644
--- a/rust/arrow/src/ipc/writer.rs
+++ b/rust/arrow/src/ipc/writer.rs
@@ -460,7 +460,7 @@
impl<W: Write> Drop for FileWriter<W> {
fn drop(&mut self) {
if !self.finished {
- self.finish().unwrap();
+ let _ = self.finish();
}
}
}
@@ -542,7 +542,7 @@
impl<W: Write> Drop for StreamWriter<W> {
fn drop(&mut self) {
if !self.finished {
- self.finish().unwrap();
+ let _ = self.finish();
}
}
}