Skip to content

Commit 77e2f9d

Browse files
committed
---
yaml --- r: 1581 b: refs/heads/master c: 3c81f16 h: refs/heads/master i: 1579: 9e28763
1 parent c074afe commit 77e2f9d

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 34e6806becf14f1b9bf0aeac1f7cc11d2aad95b1
2+
refs/heads/master: 3c81f1679e7f6880d9f3c4a9b89a5831c90fb02f
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: d1b373c30c176edc08692348167bec3a244bb823
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3

trunk/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ public String reason() {
5858
return reason;
5959
}
6060

61+
boolean isRetryable(Set<Error> retryableErrors) {
62+
for (Error retryableError : retryableErrors) {
63+
if ((retryableError.code() == null || retryableError.code().equals(this.code()))
64+
&& (retryableError.reason() == null || retryableError.reason().equals(this.reason()))) {
65+
return true;
66+
}
67+
}
68+
return false;
69+
}
70+
6171
@Override
6272
public String toString() {
6373
return MoreObjects.toStringHelper(this).add("code", code).add("reason", reason).toString();
@@ -83,7 +93,7 @@ public BaseServiceException(IOException exception, boolean idempotent) {
8393
Error error = error(((GoogleJsonResponseException) exception).getDetails());
8494
this.code = error.code;
8595
this.reason = error.reason;
86-
this.retryable = isRetryable(error);
96+
this.retryable = error.isRetryable(retryableErrors());
8797
} else {
8898
this.code = UNKNOWN_CODE;
8999
this.reason = null;
@@ -110,15 +120,15 @@ public BaseServiceException(int code, String message, String reason, boolean ide
110120
this.code = code;
111121
this.reason = reason;
112122
this.idempotent = idempotent;
113-
this.retryable = idempotent && isRetryable(new Error(code, reason));
123+
this.retryable = idempotent && new Error(code, reason).isRetryable(retryableErrors());
114124
}
115125

116126
protected Set<Error> retryableErrors() {
117127
return Collections.emptySet();
118128
}
119129

120130
protected boolean isRetryable(GoogleJsonError error) {
121-
return error != null && isRetryable(error(error));
131+
return error != null && error(error).isRetryable(retryableErrors());
122132
}
123133

124134
protected boolean isRetryable(IOException exception) {
@@ -128,16 +138,6 @@ protected boolean isRetryable(IOException exception) {
128138
return exception instanceof SocketTimeoutException;
129139
}
130140

131-
protected boolean isRetryable(Error error) {
132-
for (Error retryableError : retryableErrors()) {
133-
if ((retryableError.code() == null || retryableError.code().equals(error.code()))
134-
&& (retryableError.reason() == null || retryableError.reason().equals(error.reason()))) {
135-
return true;
136-
}
137-
}
138-
return false;
139-
}
140-
141141
/**
142142
* Returns the code associated with this exception.
143143
*/

0 commit comments

Comments
 (0)