From b6b61df5796fc29951852b54d182bd5f139a970e Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Tue, 16 Jan 2024 20:15:38 +0100 Subject: [PATCH] prepare next release; SonarLint; organize imports --- .../hazelcast/HazelcastCacheListener.java | 24 ++++++++-------- ...astReactiveBucket4jCacheConfiguration.java | 9 ++---- ...lcastSpringBucket4jCacheConfiguration.java | 9 ++---- .../IgniteBucket4jCacheConfiguration.java | 9 ++---- .../InfinispanBucket4jCacheConfiguration.java | 9 ++---- .../jedis/JedisBucket4jConfiguration.java | 1 - .../lettuce/LettuceBucket4jConfiguration.java | 1 - .../RedissonBucket4jConfiguration.java | 1 - .../redis/redisson/RedissonCacheListener.java | 22 +++++++-------- .../boot/starter/utils/Bucket4JUtils.java | 3 ++ .../filter/Bucket4JConfigurationTest.java | 28 ++++++++----------- .../filter/RateLimitBandWidthIdTest.java | 2 +- .../caffeine/CustomQueryExecutePredicate.java | 4 ++- .../examples/caffeine/DebugMetricHandler.java | 4 ++- .../config/security/SecurityConfig.java | 1 - .../controller/DebugMetricHandler.java | 5 +++- examples/gateway/pom.xml | 4 +++ .../gateway/GatewayMetricHandler.java | 8 ++++-- examples/redis-jedis/pom.xml | 4 +++ .../boot/starter/DebugMetricHandler.java | 4 ++- examples/redis-lettuce/pom.xml | 4 +++ .../boot/starter/DebugMetricHandler.java | 4 ++- .../spring/boot/starter/TestController.java | 8 ++---- examples/redis-redisson/pom.xml | 4 +++ .../boot/starter/DebugMetricHandler.java | 4 ++- .../spring/boot/starter/TestController.java | 14 ++++------ .../examples/webflux/MyController.java | 4 --- examples/webflux/pom.xml | 4 +++ .../examples/webflux/DebugMetricHandler.java | 4 ++- pom.xml | 2 +- 30 files changed, 103 insertions(+), 101 deletions(-) diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastCacheListener.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastCacheListener.java index fe4ef4de..4f054a47 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastCacheListener.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastCacheListener.java @@ -4,14 +4,12 @@ import com.hazelcast.core.EntryEvent; import com.hazelcast.map.IMap; import com.hazelcast.map.listener.EntryUpdatedListener; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; /** * This class is intended to be used as bean. - * + *

* It will listen to changes in the cache, parse them to a CacheUpdateEvent * and publish the event to the Spring ApplicationEventPublisher. * @@ -20,17 +18,17 @@ */ public class HazelcastCacheListener implements EntryUpdatedListener { - @Autowired - private ApplicationEventPublisher eventPublisher; + @Autowired + private ApplicationEventPublisher eventPublisher; - public HazelcastCacheListener(IMap map){ - map.addEntryListener(this, true); - } + public HazelcastCacheListener(IMap map) { + map.addEntryListener(this, true); + } - @Override - public void entryUpdated(EntryEvent entryEvent) { - CacheUpdateEvent updateEvent = new CacheUpdateEvent<>(entryEvent.getKey(), entryEvent.getOldValue(), entryEvent.getValue()); - eventPublisher.publishEvent(updateEvent); - } + @Override + public void entryUpdated(EntryEvent entryEvent) { + CacheUpdateEvent updateEvent = new CacheUpdateEvent<>(entryEvent.getKey(), entryEvent.getOldValue(), entryEvent.getValue()); + eventPublisher.publishEvent(updateEvent); + } } diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastReactiveBucket4jCacheConfiguration.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastReactiveBucket4jCacheConfiguration.java index f86e65f8..965aba84 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastReactiveBucket4jCacheConfiguration.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastReactiveBucket4jCacheConfiguration.java @@ -1,18 +1,15 @@ package com.giffing.bucket4j.spring.boot.starter.config.cache.hazelcast; -import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - import com.giffing.bucket4j.spring.boot.starter.config.cache.AsyncCacheResolver; import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheManager; import com.giffing.bucket4j.spring.boot.starter.config.cache.jcache.JCacheBucket4jConfiguration; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JBootProperties; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; - import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; +import org.springframework.boot.autoconfigure.condition.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; /** * Configures the asynchronous support for Hazelcast. The synchronous support of Hazelcast diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastSpringBucket4jCacheConfiguration.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastSpringBucket4jCacheConfiguration.java index 212a4002..6783b21e 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastSpringBucket4jCacheConfiguration.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/hazelcast/HazelcastSpringBucket4jCacheConfiguration.java @@ -1,20 +1,17 @@ package com.giffing.bucket4j.spring.boot.starter.config.cache.hazelcast; -import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - import com.giffing.bucket4j.spring.boot.starter.config.cache.AsyncCacheResolver; import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheManager; import com.giffing.bucket4j.spring.boot.starter.config.cache.SyncCacheResolver; import com.giffing.bucket4j.spring.boot.starter.config.cache.jcache.JCacheBucket4jConfiguration; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JBootProperties; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; - import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; import com.hazelcast.spring.cache.HazelcastCacheManager; +import org.springframework.boot.autoconfigure.condition.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; /** * Configures the asynchronous support for Hazelcast. The synchronous support of Hazelcast diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/ignite/IgniteBucket4jCacheConfiguration.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/ignite/IgniteBucket4jCacheConfiguration.java index 836388c2..ac746983 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/ignite/IgniteBucket4jCacheConfiguration.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/ignite/IgniteBucket4jCacheConfiguration.java @@ -1,16 +1,13 @@ package com.giffing.bucket4j.spring.boot.starter.config.cache.ignite; -import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - import com.giffing.bucket4j.spring.boot.starter.config.cache.AsyncCacheResolver; import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheManager; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JBootProperties; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; - import org.apache.ignite.Ignite; +import org.springframework.boot.autoconfigure.condition.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; @Configuration @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE) diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/infinispan/InfinispanBucket4jCacheConfiguration.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/infinispan/InfinispanBucket4jCacheConfiguration.java index b2df486e..47f9d676 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/infinispan/InfinispanBucket4jCacheConfiguration.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/infinispan/InfinispanBucket4jCacheConfiguration.java @@ -1,16 +1,13 @@ package com.giffing.bucket4j.spring.boot.starter.config.cache.infinispan; -import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - import com.giffing.bucket4j.spring.boot.starter.config.cache.AsyncCacheResolver; import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheManager; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JBootProperties; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; - import org.infinispan.manager.CacheContainer; +import org.springframework.boot.autoconfigure.condition.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; @Configuration @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE) diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/jedis/JedisBucket4jConfiguration.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/jedis/JedisBucket4jConfiguration.java index 086900dc..9ad11e5e 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/jedis/JedisBucket4jConfiguration.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/jedis/JedisBucket4jConfiguration.java @@ -6,7 +6,6 @@ import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; import io.github.bucket4j.redis.jedis.cas.JedisBasedProxyManager.JedisBasedProxyManagerBuilder; import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import redis.clients.jedis.JedisPool; diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/lettuce/LettuceBucket4jConfiguration.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/lettuce/LettuceBucket4jConfiguration.java index aa381702..e9a8d0c3 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/lettuce/LettuceBucket4jConfiguration.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/lettuce/LettuceBucket4jConfiguration.java @@ -7,7 +7,6 @@ import io.github.bucket4j.redis.lettuce.cas.LettuceBasedProxyManager; import io.lettuce.core.RedisClient; import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/redisson/RedissonBucket4jConfiguration.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/redisson/RedissonBucket4jConfiguration.java index 7d2480e7..35e3b02f 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/redisson/RedissonBucket4jConfiguration.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/redisson/RedissonBucket4jConfiguration.java @@ -10,7 +10,6 @@ import org.redisson.command.CommandAsyncExecutor; import org.redisson.config.Config; import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/redisson/RedissonCacheListener.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/redisson/RedissonCacheListener.java index 575e3c85..c86da329 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/redisson/RedissonCacheListener.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/redis/redisson/RedissonCacheListener.java @@ -3,14 +3,12 @@ import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheUpdateEvent; import org.redisson.api.RTopic; import org.redisson.api.RedissonClient; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.ApplicationEventPublisherAware; /** * This class is intended to be used as bean. - * + *

* It will listen to Redisson events on the {cacheName}:update channel * and publish these to the Spring ApplicationEventPublisher as CacheUpdateEvent * @@ -19,15 +17,15 @@ */ public class RedissonCacheListener { - @Autowired - private ApplicationEventPublisher eventPublisher; + @Autowired + private ApplicationEventPublisher eventPublisher; - public RedissonCacheListener(RedissonClient redisson, String cacheName) { - RTopic pubSubTopic = redisson.getTopic(cacheName); - pubSubTopic.addListener(CacheUpdateEvent.class, this::onCacheUpdateEvent); - } + public RedissonCacheListener(RedissonClient redisson, String cacheName) { + RTopic pubSubTopic = redisson.getTopic(cacheName); + pubSubTopic.addListener(CacheUpdateEvent.class, this::onCacheUpdateEvent); + } - public void onCacheUpdateEvent(CharSequence channel, CacheUpdateEvent event) { - eventPublisher.publishEvent(event); - } + public void onCacheUpdateEvent(CharSequence channel, CacheUpdateEvent event) { + eventPublisher.publishEvent(event); + } } diff --git a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/utils/Bucket4JUtils.java b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/utils/Bucket4JUtils.java index 5fd50345..a8c33c4a 100644 --- a/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/utils/Bucket4JUtils.java +++ b/bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/utils/Bucket4JUtils.java @@ -2,11 +2,14 @@ import java.util.Objects; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class Bucket4JUtils { public static ResponseEntity validateConfigurationUpdate(Bucket4JConfiguration oldConfig, Bucket4JConfiguration newConfig){ diff --git a/bucket4j-spring-boot-starter/src/test/java/com/giffing/bucket4j/spring/boot/starter/config/filter/Bucket4JConfigurationTest.java b/bucket4j-spring-boot-starter/src/test/java/com/giffing/bucket4j/spring/boot/starter/config/filter/Bucket4JConfigurationTest.java index 836f649b..aab1b563 100644 --- a/bucket4j-spring-boot-starter/src/test/java/com/giffing/bucket4j/spring/boot/starter/config/filter/Bucket4JConfigurationTest.java +++ b/bucket4j-spring-boot-starter/src/test/java/com/giffing/bucket4j/spring/boot/starter/config/filter/Bucket4JConfigurationTest.java @@ -1,26 +1,20 @@ package com.giffing.bucket4j.spring.boot.starter.config.filter; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Collections; - +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.giffing.bucket4j.spring.boot.starter.context.properties.BandWidth; import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; import com.giffing.bucket4j.spring.boot.starter.context.properties.RateLimit; - import jakarta.validation.Validation; import jakarta.validation.Validator; import jakarta.validation.ValidatorFactory; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.github.bucket4j.Bandwidth; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.mockito.Mockito; + +import java.util.Collections; + +import static org.assertj.core.api.Assertions.assertThat; public class Bucket4JConfigurationTest { @@ -41,33 +35,33 @@ public void setup() { } @Test - public void setFilterIdTest() { + void setFilterIdTest() { config.setId("id"); assert(config.getId().equals("id")); validator.validateProperty(config, "id"); //validate that autoconfigure allows string values } @Test - public void setFilterIdWithSpacesTest() { + void setFilterIdWithSpacesTest() { config.setId(" id "); assert(config.getId().equals("id")); validator.validateProperty(config, "id"); //validate that autoconfigure allows string values } @Test - public void setFilterIdNullTest() { + void setFilterIdNullTest() { config.setId(null); assert (config.getId() == null); validator.validateProperty(config, "id"); //validate that autoconfigure allows null values } @Test - public void setFilterIdEmptyStringTest(){ + void setFilterIdEmptyStringTest(){ config.setId(""); assert (config.getId() == null); } @Test - public void setFilterIdSpacesTest(){ + void setFilterIdSpacesTest(){ config.setId(" "); assert (config.getId() == null); } diff --git a/bucket4j-spring-boot-starter/src/test/java/com/giffing/bucket4j/spring/boot/starter/config/filter/RateLimitBandWidthIdTest.java b/bucket4j-spring-boot-starter/src/test/java/com/giffing/bucket4j/spring/boot/starter/config/filter/RateLimitBandWidthIdTest.java index 01c2296b..e58b8259 100644 --- a/bucket4j-spring-boot-starter/src/test/java/com/giffing/bucket4j/spring/boot/starter/config/filter/RateLimitBandWidthIdTest.java +++ b/bucket4j-spring-boot-starter/src/test/java/com/giffing/bucket4j/spring/boot/starter/config/filter/RateLimitBandWidthIdTest.java @@ -24,7 +24,7 @@ import io.github.bucket4j.TokensInheritanceStrategy; -public class RateLimitBandWidthIdTest { +class RateLimitBandWidthIdTest { final RateLimitBandWidthIdsValidator validator = new RateLimitBandWidthIdsValidator(); ConstraintValidatorContext context; diff --git a/examples/caffeine/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/caffeine/CustomQueryExecutePredicate.java b/examples/caffeine/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/caffeine/CustomQueryExecutePredicate.java index b3b0ef9d..3ac8c415 100644 --- a/examples/caffeine/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/caffeine/CustomQueryExecutePredicate.java +++ b/examples/caffeine/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/caffeine/CustomQueryExecutePredicate.java @@ -1,5 +1,6 @@ package com.giffing.bucket4j.spring.boot.starter.examples.caffeine; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import com.giffing.bucket4j.spring.boot.starter.context.ExecutePredicate; @@ -7,6 +8,7 @@ import jakarta.servlet.http.HttpServletRequest; @Component +@Slf4j public class CustomQueryExecutePredicate extends ExecutePredicate { private String query; @@ -14,7 +16,7 @@ public class CustomQueryExecutePredicate extends ExecutePredicate tags) { - System.out.println(String.format("type: %s; name: %s; tags: %s; tokens: %s", + log.info(String.format("type: %s; name: %s; tags: %s; tokens: %s", type, name, tags diff --git a/examples/ehcache/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/ehcache/config/security/SecurityConfig.java b/examples/ehcache/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/ehcache/config/security/SecurityConfig.java index 5f9424f4..4c6d67f1 100644 --- a/examples/ehcache/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/ehcache/config/security/SecurityConfig.java +++ b/examples/ehcache/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/ehcache/config/security/SecurityConfig.java @@ -3,7 +3,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; diff --git a/examples/ehcache/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/ehcache/controller/DebugMetricHandler.java b/examples/ehcache/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/ehcache/controller/DebugMetricHandler.java index 5d64f680..8305a2a4 100644 --- a/examples/ehcache/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/ehcache/controller/DebugMetricHandler.java +++ b/examples/ehcache/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/ehcache/controller/DebugMetricHandler.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler; @@ -10,11 +11,13 @@ import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricType; @Component + +@Slf4j public class DebugMetricHandler implements MetricHandler { @Override public void handle(MetricType type, String name, long tokens, List tags) { - System.out.println(String.format("type: %s; name: %s; tags: %s", + log.info(String.format("type: %s; name: %s; tags: %s", type, name, tags diff --git a/examples/gateway/pom.xml b/examples/gateway/pom.xml index ca61d12c..c76c368a 100644 --- a/examples/gateway/pom.xml +++ b/examples/gateway/pom.xml @@ -51,6 +51,10 @@ com.bucket4j bucket4j-hazelcast + + org.projectlombok + lombok + org.springframework.boot spring-boot-devtools diff --git a/examples/gateway/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/gateway/GatewayMetricHandler.java b/examples/gateway/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/gateway/GatewayMetricHandler.java index cbacb702..ece19cb7 100644 --- a/examples/gateway/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/gateway/GatewayMetricHandler.java +++ b/examples/gateway/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/gateway/GatewayMetricHandler.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler; @@ -11,13 +12,14 @@ @Component +@Slf4j public class GatewayMetricHandler implements MetricHandler { @Override public void handle(MetricType type, String name, long tokens, List tags) { - System.out.println(String.format("name: %s;type: %s; tokens: %s", type, name, tokens)); - System.out.println("\t" + tags.stream().map(mt -> mt.getKey() + ":" + mt.getValue()).collect(Collectors.joining(","))); - System.out.println("################"); + log.info(String.format("name: %s;type: %s; tokens: %s", type, name, tokens)); + log.info("\t" + tags.stream().map(mt -> mt.getKey() + ":" + mt.getValue()).collect(Collectors.joining(","))); + log.info("################"); } diff --git a/examples/redis-jedis/pom.xml b/examples/redis-jedis/pom.xml index 61de3408..78de4b10 100644 --- a/examples/redis-jedis/pom.xml +++ b/examples/redis-jedis/pom.xml @@ -47,6 +47,10 @@ jedis ${jedis.version} + + org.projectlombok + lombok + com.redis.testcontainers diff --git a/examples/redis-jedis/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java b/examples/redis-jedis/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java index 8f8ddcdd..4694e13a 100644 --- a/examples/redis-jedis/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java +++ b/examples/redis-jedis/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java @@ -3,17 +3,19 @@ import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricTagResult; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricType; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.List; import java.util.stream.Collectors; @Component +@Slf4j public class DebugMetricHandler implements MetricHandler { @Override public void handle(MetricType type, String name, long tokens, List tags) { - System.out.println(String.format("type: %s; name: %s; tags: %s; tokens: %s", + log.info(String.format("type: %s; name: %s; tags: %s; tokens: %s", type, name, tags diff --git a/examples/redis-lettuce/pom.xml b/examples/redis-lettuce/pom.xml index f9a432e6..dee6d6bd 100644 --- a/examples/redis-lettuce/pom.xml +++ b/examples/redis-lettuce/pom.xml @@ -50,6 +50,10 @@ org.apache.commons commons-pool2 + + org.projectlombok + lombok + com.redis.testcontainers testcontainers-redis-junit diff --git a/examples/redis-lettuce/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java b/examples/redis-lettuce/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java index 8f8ddcdd..4694e13a 100644 --- a/examples/redis-lettuce/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java +++ b/examples/redis-lettuce/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java @@ -3,17 +3,19 @@ import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricTagResult; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricType; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.List; import java.util.stream.Collectors; @Component +@Slf4j public class DebugMetricHandler implements MetricHandler { @Override public void handle(MetricType type, String name, long tokens, List tags) { - System.out.println(String.format("type: %s; name: %s; tags: %s; tokens: %s", + log.info(String.format("type: %s; name: %s; tags: %s; tokens: %s", type, name, tags diff --git a/examples/redis-lettuce/src/main/java/com/giffing/bucket4j/spring/boot/starter/TestController.java b/examples/redis-lettuce/src/main/java/com/giffing/bucket4j/spring/boot/starter/TestController.java index ec520663..68ea4924 100644 --- a/examples/redis-lettuce/src/main/java/com/giffing/bucket4j/spring/boot/starter/TestController.java +++ b/examples/redis-lettuce/src/main/java/com/giffing/bucket4j/spring/boot/starter/TestController.java @@ -1,18 +1,14 @@ package com.giffing.bucket4j.spring.boot.starter; +import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheManager; +import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; import com.giffing.bucket4j.spring.boot.starter.utils.Bucket4JUtils; import jakarta.validation.ConstraintViolation; -import jakarta.validation.Valid; import jakarta.validation.Validator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.http.ResponseEntity; -import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; -import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheManager; -import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; - import java.util.List; import java.util.Set; diff --git a/examples/redis-redisson/pom.xml b/examples/redis-redisson/pom.xml index e270666a..5938ded3 100644 --- a/examples/redis-redisson/pom.xml +++ b/examples/redis-redisson/pom.xml @@ -51,6 +51,10 @@ org.apache.commons commons-pool2 + + org.projectlombok + lombok + com.redis.testcontainers testcontainers-redis-junit diff --git a/examples/redis-redisson/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java b/examples/redis-redisson/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java index 8f8ddcdd..4694e13a 100644 --- a/examples/redis-redisson/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java +++ b/examples/redis-redisson/src/main/java/com/giffing/bucket4j/spring/boot/starter/DebugMetricHandler.java @@ -3,17 +3,19 @@ import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricTagResult; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricType; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.List; import java.util.stream.Collectors; @Component +@Slf4j public class DebugMetricHandler implements MetricHandler { @Override public void handle(MetricType type, String name, long tokens, List tags) { - System.out.println(String.format("type: %s; name: %s; tags: %s; tokens: %s", + log.info(String.format("type: %s; name: %s; tags: %s; tokens: %s", type, name, tags diff --git a/examples/redis-redisson/src/main/java/com/giffing/bucket4j/spring/boot/starter/TestController.java b/examples/redis-redisson/src/main/java/com/giffing/bucket4j/spring/boot/starter/TestController.java index b5d04d54..6472f889 100644 --- a/examples/redis-redisson/src/main/java/com/giffing/bucket4j/spring/boot/starter/TestController.java +++ b/examples/redis-redisson/src/main/java/com/giffing/bucket4j/spring/boot/starter/TestController.java @@ -1,20 +1,16 @@ package com.giffing.bucket4j.spring.boot.starter; -import java.util.List; -import java.util.Set; - +import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheManager; +import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; +import com.giffing.bucket4j.spring.boot.starter.utils.Bucket4JUtils; import jakarta.validation.ConstraintViolation; -import jakarta.validation.Valid; import jakarta.validation.Validator; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; -import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; -import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheManager; -import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; -import com.giffing.bucket4j.spring.boot.starter.utils.Bucket4JUtils; +import java.util.List; +import java.util.Set; @RestController public class TestController { diff --git a/examples/webflux-infinispan/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/webflux/MyController.java b/examples/webflux-infinispan/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/webflux/MyController.java index 2650b7d5..5ca7dfe9 100644 --- a/examples/webflux-infinispan/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/webflux/MyController.java +++ b/examples/webflux-infinispan/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/webflux/MyController.java @@ -4,14 +4,10 @@ import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration; import com.giffing.bucket4j.spring.boot.starter.utils.Bucket4JUtils; import jakarta.validation.ConstraintViolation; -import jakarta.validation.Valid; import jakarta.validation.Validator; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.http.ResponseEntity; -import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; - import reactor.core.publisher.Mono; import java.util.List; diff --git a/examples/webflux/pom.xml b/examples/webflux/pom.xml index 84273cf9..d4321459 100644 --- a/examples/webflux/pom.xml +++ b/examples/webflux/pom.xml @@ -51,6 +51,10 @@ com.hazelcast hazelcast-spring + + org.projectlombok + lombok + org.springframework.boot spring-boot-starter-test diff --git a/examples/webflux/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/webflux/DebugMetricHandler.java b/examples/webflux/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/webflux/DebugMetricHandler.java index d417e972..6019d36f 100644 --- a/examples/webflux/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/webflux/DebugMetricHandler.java +++ b/examples/webflux/src/main/java/com/giffing/bucket4j/spring/boot/starter/examples/webflux/DebugMetricHandler.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler; @@ -10,11 +11,12 @@ import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricType; @Component +@Slf4j public class DebugMetricHandler implements MetricHandler { @Override public void handle(MetricType type, String name, long tokens, List tags) { - System.out.println(String.format("type: %s; name: %s; tags: %s", + log.info(String.format("type: %s; name: %s; tags: %s", type, name, tags diff --git a/pom.xml b/pom.xml index e3bfbe55..242c346c 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ bucket4j-spring-boot-starter-parent-0.3.4 - 0.10.1 + 0.10.2 UTF-8 UTF-8 17