From 7703ab2fa92660efa0a686e0f92e57248ca820f5 Mon Sep 17 00:00:00 2001 From: Philipendulum Date: Tue, 3 Dec 2024 22:01:23 +0100 Subject: [PATCH] pschnayder: Updating the StreamWriterClosedException to include client side mitigation suggestions from the public documentation (#2784) * pschnayder: Updating the StreamWriterClosedException to include client side mitigation suggestions from the public documentation * Adding a period before the updated error message --- .../bigquery/storage/v1/ConnectionWorker.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java index 783a079f7..a7a43b515 100644 --- a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java +++ b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java @@ -585,11 +585,21 @@ private ApiFuture appendInternal( } if (connectionFinalStatus != null) { + String connectionFinalStatusString; + if (connectionFinalStatus + .toString() + .contains("com.google.api.gax.rpc.UnavailableException")) { + connectionFinalStatusString = + connectionFinalStatus.toString() + + ". This is a most likely a transient condition and may be corrected by retrying" + + " with a backoff."; + } else { + connectionFinalStatusString = connectionFinalStatus.toString(); + } requestWrapper.appendResult.setException( new Exceptions.StreamWriterClosedException( Status.fromCode(Status.Code.FAILED_PRECONDITION) - .withDescription( - "Connection is closed due to " + connectionFinalStatus.toString()), + .withDescription("Connection is closed due to " + connectionFinalStatusString), streamName, writerId)); return requestWrapper.appendResult;