From 73f0fe1ecacca7a702a75f6e468ac930ba9675f8 Mon Sep 17 00:00:00 2001 From: zpencer Date: Tue, 19 Dec 2017 16:13:24 -0800 Subject: [PATCH] gae: retry on exceptions too, not just on non 200OK (#3885) --- gae-interop-testing/gae-jdk7/build.gradle | 17 ++++++++++++----- gae-interop-testing/gae-jdk8/build.gradle | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/gae-interop-testing/gae-jdk7/build.gradle b/gae-interop-testing/gae-jdk7/build.gradle index 1047f4f4d8..216e16bfb1 100644 --- a/gae-interop-testing/gae-jdk7/build.gradle +++ b/gae-interop-testing/gae-jdk7/build.gradle @@ -122,13 +122,20 @@ task runInteropTestRemote(dependsOn: 'appengineDeploy') { // Retry in case GAE is slow and times out int maxRetries = 5 - def result = null + String result = null + Throwable caught = null for (int attempt = 0; attempt < maxRetries; attempt++) { - result = client.newCall(interopRequest).execute() - if (result.code() == 200) { - return + try { + def response = client.newCall(interopRequest).execute() + result = response.body().string() + if (response.code() == 200) { + return + } + } catch (Throwable t) { + caught = t + logger.log(LogLevel.ERROR, "caught exception. will retry if possible", t) } } - throw new GradleException("Interop test failed: " + result?.body()?.string()) + throw new GradleException("Interop test failed:\nresponse: ${result}\nthrowable:${caught}") } } diff --git a/gae-interop-testing/gae-jdk8/build.gradle b/gae-interop-testing/gae-jdk8/build.gradle index a24b4c720f..951d476ad8 100644 --- a/gae-interop-testing/gae-jdk8/build.gradle +++ b/gae-interop-testing/gae-jdk8/build.gradle @@ -129,13 +129,20 @@ task runInteropTestRemote(dependsOn: 'appengineDeploy') { // Retry in case GAE is slow and times out int maxRetries = 5 - def result = null + String result = null + Throwable caught = null for (int attempt = 0; attempt < maxRetries; attempt++) { - result = client.newCall(interopRequest).execute() - if (result.code() == 200) { - return + try { + def response = client.newCall(interopRequest).execute() + result = response.body().string() + if (response.code() == 200) { + return + } + } catch (Throwable t) { + caught = t + logger.log(LogLevel.ERROR, "caught exception. will retry if possible", t) } } - throw new GradleException("Interop test failed: " + result?.body()?.string()) + throw new GradleException("Interop test failed:\nresponse: ${result}\nthrowable:${caught}") } }