Skip to content

Commit

Permalink
Add ExchangeReaderWriter.getResult()
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanCutler committed Oct 6, 2023
1 parent 4f66c22 commit 01e5b45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,16 @@ public ClientStreamListener getWriter() {
return writer;
}

/**
* Make sure stream is drained. You must call this to be notified of any errors that may have
* happened after the exchange is complete. This should be called after `getWriter().completed()`
* instead of `getWriter().getResult`.
*/
public void getResult() {
// After exchange is complete, make sure stream is drained to propagate errors through reader
reader.next();
}

/** Shut down the streams in this call. */
@Override
public void close() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public void testDoExchangeError() throws Exception {
stream.getWriter().completed();

// Must call reader.next() to get any errors after exchange, will return false if no error
final FlightRuntimeException fre = assertThrows(FlightRuntimeException.class, reader::next);
final FlightRuntimeException fre = assertThrows(FlightRuntimeException.class, stream::getResult);
assertEquals("error completing exchange", fre.status().description());
}
}
Expand Down Expand Up @@ -438,7 +438,7 @@ public void testCloseWithMetadata() throws Exception {

// Close our write channel and ensure the server also closes theirs
stream.getWriter().completed();
assertFalse(reader.next());
stream.getResult();

// Not necessary to close reader here, but check closing twice doesn't lead to negative refcnt from metadata
stream.getReader().close();
Expand Down

0 comments on commit 01e5b45

Please sign in to comment.