Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -268,6 +270,9 @@ private HttpResponse doSend(HttpRequest request) throws IOException {
// JsonWriter often writes one character at a time.
dataEncoder.encode(
request.requestBody, new BufferedWriter(new OutputStreamWriter(outputStream)));
} catch (ConnectException | UnknownHostException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud: This seems like a pretty conservative approach, as opposed to treating all IO Exceptions as retry-able.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah exactly - the reason we did this is there are legit IO Exceptions that would not be retryable, eg. encoding errors of some sort

Logging.e(LOG_TAG, "Couldn't open connection, returning with 500", e);
return new HttpResponse(500, null, 0);
} catch (EncodingException | IOException e) {
Logging.e(LOG_TAG, "Couldn't encode request, returning with 400", e);
return new HttpResponse(400, null, 0);
Expand Down