Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SocketException and 'insufficient data written' to retryable exceptions #1187

Merged
merged 1 commit into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
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 @@ -23,6 +23,7 @@

import java.io.IOException;
import java.io.Serializable;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.Collections;
import java.util.Objects;
Expand Down Expand Up @@ -187,7 +188,10 @@ protected boolean isRetryable(boolean idempotent, Error error) {
}

protected boolean isRetryable(boolean idempotent, IOException exception) {
return idempotent && exception instanceof SocketTimeoutException;
boolean exceptionIsRetryable = exception instanceof SocketTimeoutException
|| exception instanceof SocketException
|| "insufficient data written".equals(exception.getMessage());

This comment was marked as spam.

This comment was marked as spam.

return idempotent && exceptionIsRetryable;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.junit.Test;

import java.io.IOException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.Set;

Expand Down Expand Up @@ -101,6 +102,21 @@ public void testBaseServiceException() {
serviceException = new BaseServiceException(exception, true);
assertTrue(serviceException.retryable());
assertTrue(serviceException.idempotent());
assertNull(serviceException.getMessage());
assertEquals(exception, serviceException.getCause());

exception = new SocketException();
serviceException = new BaseServiceException(exception, true);
assertTrue(serviceException.retryable());
assertTrue(serviceException.idempotent());
assertNull(serviceException.getMessage());
assertEquals(exception, serviceException.getCause());

exception = new IOException("insufficient data written");
serviceException = new BaseServiceException(exception, true);
assertTrue(serviceException.retryable());
assertTrue(serviceException.idempotent());
assertEquals("insufficient data written", serviceException.getMessage());
assertEquals(exception, serviceException.getCause());

GoogleJsonError error = new GoogleJsonError();
Expand Down