diff --git a/xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java b/xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java index c1090110afd5..8b1f159ec072 100644 --- a/xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java +++ b/xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java @@ -56,6 +56,10 @@ public RlqsEngine( public RlqsRateLimitResult rateLimit(HttpMatchInput input) { RlqsBucketSettings bucketSettings = bucketMatchers.match(input); RlqsBucketId bucketId = bucketSettings.toBucketId(input); + // Special case when bucket id builder not set. + if (bucketId == null) { + return rateLimitWithoutReports(bucketSettings); + } RlqsBucket bucket = bucketCache.getOrCreate(bucketId, bucketSettings, newBucket -> { // Called if a new bucket was created. scheduleImmediateReport(newBucket); @@ -64,6 +68,13 @@ public RlqsRateLimitResult rateLimit(HttpMatchInput input) { return bucket.rateLimit(); } + private static RlqsRateLimitResult rateLimitWithoutReports(RlqsBucketSettings bucketSettings) { + if (bucketSettings.noAssignmentStrategy().rateLimit()) { + return RlqsRateLimitResult.deny(bucketSettings.denyResponse()); + } + return RlqsRateLimitResult.allow(); + } + private void onBucketsUpdate(List bucketActions) { // TODO(sergiitk): [impl] ensure no more than 1 update at a time. for (RlqsUpdateBucketAction bucketAction : bucketActions) {