Skip to content

Commit 88da521

Browse files
committed
---
yaml --- r: 2711 b: refs/heads/update-datastore c: 3c81f16 h: refs/heads/master i: 2709: cb97c07 2707: 00b1a13 2703: c14a5c9
1 parent 6f5298a commit 88da521

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
@@ -5,7 +5,7 @@ refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
66
refs/heads/pubsub-alpha: 1a0e970f265af871e02274085b9662b3fe29058b
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
8-
refs/heads/update-datastore: 34e6806becf14f1b9bf0aeac1f7cc11d2aad95b1
8+
refs/heads/update-datastore: 3c81f1679e7f6880d9f3c4a9b89a5831c90fb02f
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
1010
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd
1111
refs/tags/v0.0.11: ffbfba48a6426ff63c08ff2117e58681f251fbf2

branches/update-datastore/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)