Skip to content

Commit a83b79d

Browse files
committed
---
yaml --- r: 6765 b: refs/heads/tswast-patch-1 c: 3c81f16 h: refs/heads/master i: 6763: f7c3a56
1 parent bb1513f commit a83b79d

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
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 34e6806becf14f1b9bf0aeac1f7cc11d2aad95b1
60+
refs/heads/tswast-patch-1: 3c81f1679e7f6880d9f3c4a9b89a5831c90fb02f
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/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)