From 68d1eef689f2b71304003ae7f1f813f3ebb20b5a Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Wed, 8 May 2024 01:53:31 -0400 Subject: [PATCH] Minor: avoid (likely unreachable) panic in FlightClient (#5734) --- arrow-flight/src/client.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arrow-flight/src/client.rs b/arrow-flight/src/client.rs index f5f28f683a9d..3f62b256d56e 100644 --- a/arrow-flight/src/client.rs +++ b/arrow-flight/src/client.rs @@ -710,10 +710,14 @@ impl Stream for FallibleRequestStream { match ready!(request_streams.poll_next_unpin(cx)) { Some(Ok(data)) => Poll::Ready(Some(data)), Some(Err(e)) => { - // unwrap() here is safe, ownership of sender will - // be moved only once as this stream will not be polled - // again - let _ = pinned.sender.take().unwrap().send(e); + // in theory this should only ever be called once + // as this stream should not be polled again after returning + // None, however we still check for None to be safe + if let Some(sender) = pinned.sender.take() { + // an error means the other end of the channel is not around + // to receive the error, so ignore it + let _ = sender.send(e); + } Poll::Ready(None) } None => Poll::Ready(None),