From 39b275412155805c7cf4ed1f5d1651c494414943 Mon Sep 17 00:00:00 2001 From: Fishtail <49390359+fuyuwei01@users.noreply.github.com> Date: Thu, 15 Aug 2024 17:05:41 +0800 Subject: [PATCH] fix:fix the ratelimit bug (#1389) Co-authored-by: fredrikliu <139424001+fredrikliu@users.noreply.github.com> --- CHANGELOG.md | 1 + .../polaris/ratelimit/filter/QuotaCheckReactiveFilter.java | 4 ++-- .../polaris/ratelimit/filter/QuotaCheckServletFilter.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25fb47a93..6da51403d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,3 +15,4 @@ - [fix: fix lossless deregister failed when no healthcheck configured](https://github.com/Tencent/spring-cloud-tencent/pull/1385) - [feat:add zero protection.](https://github.com/Tencent/spring-cloud-tencent/pull/1386) - [fix:fix no registry when lossless is disabled.](https://github.com/Tencent/spring-cloud-tencent/pull/1388) +- [fix:fix the ratelimit bug](https://github.com/Tencent/spring-cloud-tencent/pull/1389) \ No newline at end of file diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java index f7ce8d21b..f6bf04706 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java @@ -128,12 +128,12 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered { if (Objects.nonNull(quotaResponse.getActiveRule())) { try { String encodedActiveRuleName = URLEncoder.encode( - quotaResponse.getActiveRule().getName().getValue(), UTF_8); + quotaResponse.getActiveRuleName(), UTF_8); response.getHeaders().add(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME, encodedActiveRuleName); } catch (UnsupportedEncodingException e) { LOG.error("Cannot encode {} for header internal-callee-activerule.", - quotaResponse.getActiveRule().getName().getValue(), e); + quotaResponse.getActiveRuleName(), e); } } return response.writeWith(Mono.just(dataBuffer)); diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java index 2f4a56eac..7266e5b54 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java @@ -121,12 +121,12 @@ public class QuotaCheckServletFilter extends OncePerRequestFilter { if (Objects.nonNull(quotaResponse.getActiveRule())) { try { String encodedActiveRuleName = URLEncoder.encode( - quotaResponse.getActiveRule().getName().getValue(), UTF_8); + quotaResponse.getActiveRuleName(), UTF_8); response.addHeader(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME, encodedActiveRuleName); } catch (UnsupportedEncodingException e) { LOG.error("Cannot encode {} for header internal-callee-activerule.", - quotaResponse.getActiveRule().getName().getValue(), e); + quotaResponse.getActiveRuleName(), e); } } return;