This repository was archived by the owner on Feb 24, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
google-cloud-bigquerystorage/src
main/java/com/google/cloud/bigquery/storage/v1
test/java/com/google/cloud/bigquery/storage/v1 Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 2727
2828/** Exceptions for Storage Client Libraries. */
2929public final class Exceptions {
30+ public static class WriterClosedException extends Exception {
31+ public WriterClosedException (String streamName ) {
32+ super ("Writer closed on: " + streamName );
33+ }
34+ }
3035 /** Main Storage Exception. Might contain map of streams to errors for that stream. */
3136 public static class StorageException extends RuntimeException {
3237
Original file line number Diff line number Diff line change @@ -502,11 +502,13 @@ private AppendRowsRequest prepareRequestBasedOnPosition(
502502 }
503503
504504 private void cleanupInflightRequests () {
505- Throwable finalStatus ;
505+ Throwable finalStatus = new Exceptions . WriterClosedException ( streamName ) ;
506506 Deque <AppendRequestAndResponse > localQueue = new LinkedList <AppendRequestAndResponse >();
507507 this .lock .lock ();
508508 try {
509- finalStatus = this .connectionFinalStatus ;
509+ if (this .connectionFinalStatus != null ) {
510+ finalStatus = this .connectionFinalStatus ;
511+ }
510512 while (!this .inflightRequestQueue .isEmpty ()) {
511513 localQueue .addLast (pollInflightRequestQueue ());
512514 }
Original file line number Diff line number Diff line change @@ -638,4 +638,12 @@ public void testRetryAfterAllRecordsInflight() throws Exception {
638638 assertEquals (1 , appendFuture2 .get ().getAppendResult ().getOffset ().getValue ());
639639 }
640640 }
641+
642+ @ Test
643+ public void testWriterClosedStream () throws Exception {
644+ try (StreamWriter writer = getTestStreamWriter ()) {
645+ // Writer is closed without any traffic.
646+ TimeUnit .SECONDS .sleep (1 );
647+ }
648+ }
641649}
You can’t perform that action at this time.
0 commit comments