Skip to content

Commit 08507fa

Browse files
authored
Retry GoogleDataTransport Connection Errors (#1705)
1 parent 8181416 commit 08507fa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

transport/transport-backend-cct/src/main/java/com/google/android/datatransport/cct/CctTransportBackend.java

+5
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@
4848
import java.io.InputStreamReader;
4949
import java.io.OutputStream;
5050
import java.io.OutputStreamWriter;
51+
import java.net.ConnectException;
5152
import java.net.HttpURLConnection;
5253
import java.net.MalformedURLException;
5354
import java.net.URL;
55+
import java.net.UnknownHostException;
5456
import java.nio.charset.Charset;
5557
import java.util.ArrayList;
5658
import java.util.Calendar;
@@ -268,6 +270,9 @@ private HttpResponse doSend(HttpRequest request) throws IOException {
268270
// JsonWriter often writes one character at a time.
269271
dataEncoder.encode(
270272
request.requestBody, new BufferedWriter(new OutputStreamWriter(outputStream)));
273+
} catch (ConnectException | UnknownHostException e) {
274+
Logging.e(LOG_TAG, "Couldn't open connection, returning with 500", e);
275+
return new HttpResponse(500, null, 0);
271276
} catch (EncodingException | IOException e) {
272277
Logging.e(LOG_TAG, "Couldn't encode request, returning with 400", e);
273278
return new HttpResponse(400, null, 0);

0 commit comments

Comments
 (0)