From bbeb39830ed9a909a98ff48f46770c8ceef2934f Mon Sep 17 00:00:00 2001 From: Philipp Shnayder Date: Tue, 26 Nov 2024 14:08:17 +0000 Subject: [PATCH 1/2] pschnayder: Updating the StreamWriterClosedException to include client side mitigation suggestions from the public documentation --- .../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..fcdffba05 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; From a3f8f5d30cdb5ae44e244600f016ece29a7ea886 Mon Sep 17 00:00:00 2001 From: Philipp Shnayder Date: Mon, 2 Dec 2024 15:17:55 +0000 Subject: [PATCH 2/2] Adding a period before the updated error message --- .../com/google/cloud/bigquery/storage/v1/ConnectionWorker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fcdffba05..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 @@ -591,7 +591,7 @@ private ApiFuture appendInternal( .contains("com.google.api.gax.rpc.UnavailableException")) { connectionFinalStatusString = connectionFinalStatus.toString() - + " This is a most likely a transient condition and may be corrected by retrying" + + ". This is a most likely a transient condition and may be corrected by retrying" + " with a backoff."; } else { connectionFinalStatusString = connectionFinalStatus.toString();