|
32 | 32 | */ |
33 | 33 | public class BaseServiceException extends RuntimeException { |
34 | 34 |
|
| 35 | + private static final long serialVersionUID = 759921776378760835L; |
| 36 | + public static final int UNKNOWN_CODE = 0; |
| 37 | + |
| 38 | + private final int code; |
| 39 | + private final boolean retryable; |
| 40 | + private final String reason; |
| 41 | + private final boolean idempotent; |
| 42 | + private final String location; |
| 43 | + private final String debugInfo; |
| 44 | + |
35 | 45 | protected static final class Error implements Serializable { |
36 | 46 |
|
37 | 47 | private static final long serialVersionUID = -4019600198652965721L; |
@@ -79,16 +89,6 @@ public int hashCode() { |
79 | 89 | } |
80 | 90 | } |
81 | 91 |
|
82 | | - private static final long serialVersionUID = 759921776378760835L; |
83 | | - public static final int UNKNOWN_CODE = 0; |
84 | | - |
85 | | - private final int code; |
86 | | - private final boolean retryable; |
87 | | - private final String reason; |
88 | | - private final boolean idempotent; |
89 | | - private final String location; |
90 | | - private final String debugInfo; |
91 | | - |
92 | 92 | public BaseServiceException(IOException exception, boolean idempotent) { |
93 | 93 | super(message(exception), exception); |
94 | 94 | int code = UNKNOWN_CODE; |
@@ -198,6 +198,31 @@ protected String debugInfo() { |
198 | 198 | return debugInfo; |
199 | 199 | } |
200 | 200 |
|
| 201 | + @Override |
| 202 | + public boolean equals(Object obj) { |
| 203 | + if (obj == this) { |
| 204 | + return true; |
| 205 | + } |
| 206 | + if (!(obj instanceof BaseServiceException)) { |
| 207 | + return false; |
| 208 | + } |
| 209 | + BaseServiceException other = (BaseServiceException) obj; |
| 210 | + return Objects.equals(getCause(), other.getCause()) |
| 211 | + && Objects.equals(getMessage(), other.getMessage()) |
| 212 | + && code == other.code |
| 213 | + && retryable == other.retryable |
| 214 | + && Objects.equals(reason, other.reason) |
| 215 | + && idempotent == other.idempotent |
| 216 | + && Objects.equals(location, other.location) |
| 217 | + && Objects.equals(debugInfo, other.debugInfo); |
| 218 | + } |
| 219 | + |
| 220 | + @Override |
| 221 | + public int hashCode() { |
| 222 | + return Objects.hash(getCause(), getMessage(), code, retryable, reason, idempotent, location, |
| 223 | + debugInfo); |
| 224 | + } |
| 225 | + |
201 | 226 | protected static String reason(GoogleJsonError error) { |
202 | 227 | if (error.getErrors() != null && !error.getErrors().isEmpty()) { |
203 | 228 | return error.getErrors().get(0).getReason(); |
|
0 commit comments