From 5792b49671f0bbdee2667745bc9e575315181acb Mon Sep 17 00:00:00 2001 From: Michael Folz Date: Mon, 13 Jan 2025 07:32:35 +0100 Subject: [PATCH] #424 - Replace deprecated calls to bucket4j library - replace calls to Bandwith constructor with BandwithBuilder - replace oauth token request constructor call with call to builder --- .../query/broker/OAuthInterceptor.java | 3 ++- .../query/ratelimiting/RateLimitingService.java | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/numcodex/feasibility_gui_backend/query/broker/OAuthInterceptor.java b/src/main/java/de/numcodex/feasibility_gui_backend/query/broker/OAuthInterceptor.java index 1358a2b2..479b0fc0 100644 --- a/src/main/java/de/numcodex/feasibility_gui_backend/query/broker/OAuthInterceptor.java +++ b/src/main/java/de/numcodex/feasibility_gui_backend/query/broker/OAuthInterceptor.java @@ -60,7 +60,8 @@ public String getToken() { private HTTPRequest getTokenRequest() throws GeneralException, IOException { if (tokenRequest == null) { - tokenRequest = new TokenRequest(getTokenUri(), clientAuth, new ClientCredentialsGrant()).toHTTPRequest(); + tokenRequest = new TokenRequest.Builder(getTokenUri(), clientAuth, new ClientCredentialsGrant()) + .build().toHTTPRequest(); } return tokenRequest; } diff --git a/src/main/java/de/numcodex/feasibility_gui_backend/query/ratelimiting/RateLimitingService.java b/src/main/java/de/numcodex/feasibility_gui_backend/query/ratelimiting/RateLimitingService.java index 1525dc1a..6f136076 100644 --- a/src/main/java/de/numcodex/feasibility_gui_backend/query/ratelimiting/RateLimitingService.java +++ b/src/main/java/de/numcodex/feasibility_gui_backend/query/ratelimiting/RateLimitingService.java @@ -1,6 +1,7 @@ package de.numcodex.feasibility_gui_backend.query.ratelimiting; import io.github.bucket4j.Bandwidth; +import io.github.bucket4j.BandwidthBuilder; import io.github.bucket4j.Bucket; import io.github.bucket4j.Refill; import lombok.Getter; @@ -62,19 +63,19 @@ public void addTokensToDetailedObfuscatedResultBucket(String userId, int amount) private Bucket newSummaryResultBucket(String userId) { return Bucket.builder() - .addLimit(Bandwidth.classic(1, Refill.intervally(1, intervalPollingSummary))) + .addLimit(limit -> limit.capacity(1).refillIntervally(1, intervalPollingSummary)) .build(); } private Bucket newDetailedResultBucket(String userId) { return Bucket.builder() - .addLimit(Bandwidth.classic(1, Refill.intervally(1, intervalPollingDetailed))) + .addLimit(limit -> limit.capacity(1).refillIntervally(1, intervalPollingDetailed)) .build(); } private Bucket newViewDetailedObfuscatedResultBucket(String userId) { return Bucket.builder() - .addLimit(Bandwidth.classic(amountDetailedObfuscated, Refill.intervally(1, intervalDetailedObfuscated))) + .addLimit(limit -> limit.capacity(1).refillIntervally(1, intervalDetailedObfuscated)) .build(); }