Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit 441dcf2

Browse files
committed
fix: extract strings to constants
1 parent 4fc862a commit 441dcf2

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AdminRequestsPerMinuteExceededException.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
public class AdminRequestsPerMinuteExceededException extends SpannerException {
2626
private static final long serialVersionUID = -6395746612598975751L;
2727

28+
static final String ADMIN_REQUESTS_LIMIT_KEY = "quota_limit";
29+
static final String ADMIN_REQUESTS_LIMIT_VALUE = "AdminMethodQuotaPerMinutePerProject";
30+
2831
/** Private constructor. Use {@link SpannerExceptionFactory} to create instances. */
2932
AdminRequestsPerMinuteExceededException(
3033
DoNotConstructDirectly token, @Nullable String message, @Nullable Throwable cause) {

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerExceptionFactory.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,11 @@ static SpannerException newSpannerExceptionPreformatted(
236236
case RESOURCE_EXHAUSTED:
237237
ErrorInfo info = extractErrorInfo(cause);
238238
if (info != null
239-
&& info.getMetadataMap().containsKey("quota_limit")
240-
&& "AdminMethodQuotaPerMinutePerProject"
241-
.equals(info.getMetadataMap().get("quota_limit"))) {
239+
&& info.getMetadataMap()
240+
.containsKey(AdminRequestsPerMinuteExceededException.ADMIN_REQUESTS_LIMIT_KEY)
241+
&& AdminRequestsPerMinuteExceededException.ADMIN_REQUESTS_LIMIT_VALUE.equals(
242+
info.getMetadataMap()
243+
.get(AdminRequestsPerMinuteExceededException.ADMIN_REQUESTS_LIMIT_KEY))) {
242244
return new AdminRequestsPerMinuteExceededException(token, message, cause);
243245
}
244246
case NOT_FOUND:

0 commit comments

Comments
 (0)