Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 22987b6

Browse files
committed
fix: improve getErrorDescFromResponse() performance
1 parent ad438dc commit 22987b6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryRetryAlgorithm.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

21+
import com.google.api.client.json.GenericJson;
2122
import com.google.api.gax.retrying.ResultRetryAlgorithm;
2223
import com.google.api.gax.retrying.ResultRetryAlgorithmWithContext;
2324
import com.google.api.gax.retrying.RetryAlgorithm;
@@ -223,6 +224,16 @@ private String getErrorDescFromResponse(ResponseT previousResponse) {
223224
known case where a response with status code 200 may contain an error message
224225
*/
225226
try {
227+
if (previousResponse instanceof GenericJson) {
228+
if (((GenericJson)previousResponse).containsKey("status")){
229+
Object o1 = ((GenericJson)previousResponse).get("status");
230+
if (o1 instanceof GenericJson && ((GenericJson)o1).containsKey("errorResult")){
231+
Object o2 = ((GenericJson)o1).get("errorStatus");
232+
return ((GenericJson)o2).get("message").toString();
233+
}
234+
}
235+
return null;
236+
}
226237
JsonObject responseJson =
227238
JsonParser.parseString(previousResponse.toString()).getAsJsonObject();
228239
if (responseJson.has("status") && responseJson.getAsJsonObject("status").has("errorResult")) {

0 commit comments

Comments
 (0)