diff --git a/src/main/java/com/navercorp/arcus/spring/cache/ArcusCache.java b/src/main/java/com/navercorp/arcus/spring/cache/ArcusCache.java
index 78368de..5ad0b6f 100644
--- a/src/main/java/com/navercorp/arcus/spring/cache/ArcusCache.java
+++ b/src/main/java/com/navercorp/arcus/spring/cache/ArcusCache.java
@@ -76,11 +76,12 @@
* 이렇게 설정했을때, 캐시의 키 값으로 생성되는 값은 beta-member:메서드 매개변수로 만든 문자열이 됩니다.
*
*/
-@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"})
+@SuppressWarnings({"DeprecatedIsStillUsed"})
public class ArcusCache extends AbstractValueAdaptingCache {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ // TODO: make name, arcusClient final
private String name;
private ArcusClientPool arcusClient;
private final ArcusCacheConfiguration configuration;
@@ -102,8 +103,12 @@ public ArcusCache(String name, ArcusClientPool clientPool) {
public ArcusCache(String name, ArcusClientPool clientPool, ArcusCacheConfiguration configuration) {
super(requireNonNull(configuration).isAllowNullValues());
- this.setName(name);
- this.setArcusClient(clientPool);
+
+ Assert.notNull(name, "ArcusCache's 'name' property must have a value.");
+ Assert.notNull(clientPool, "ArcusCache's 'arcusClient' property must not be null.");
+
+ this.name = name;
+ this.arcusClient = clientPool;
this.configuration = configuration;
}
diff --git a/src/main/java/com/navercorp/arcus/spring/cache/ArcusCacheManager.java b/src/main/java/com/navercorp/arcus/spring/cache/ArcusCacheManager.java
index 3a46de2..b4af257 100644
--- a/src/main/java/com/navercorp/arcus/spring/cache/ArcusCacheManager.java
+++ b/src/main/java/com/navercorp/arcus/spring/cache/ArcusCacheManager.java
@@ -41,8 +41,8 @@
*/
public class ArcusCacheManager extends AbstractTransactionSupportingCacheManager implements DisposableBean {
private final ArcusClientPool client;
- protected ArcusCacheConfiguration defaultConfiguration;
- protected Map initialCacheConfigs;
+ private final ArcusCacheConfiguration defaultConfiguration;
+ private final Map initialCacheConfigs;
private boolean internalClient;
/**
@@ -53,11 +53,8 @@ public class ArcusCacheManager extends AbstractTransactionSupportingCacheManager
* @param defaultConfiguration 정의되지 않은 캐시의 기본 설정
* @param initialCacheConfigs 생성할 캐시들의 이름과 설정들의 집합
*/
- public ArcusCacheManager(
- ArcusClientPool client,
- ArcusCacheConfiguration defaultConfiguration,
- Map initialCacheConfigs
- ) {
+ public ArcusCacheManager(ArcusClientPool client, ArcusCacheConfiguration defaultConfiguration,
+ Map initialCacheConfigs) {
this.client = client;
this.defaultConfiguration = defaultConfiguration;
this.initialCacheConfigs = initialCacheConfigs;
@@ -67,26 +64,19 @@ public ArcusCacheManager(
/**
* 캐시 매니저 내부에서 Arcus 클라이언트를 생성 및 소멸을 관리하기 위한 생성자.
*
- * @param adminAddress Arcus 클라이언트를 생성하기 위해 필요한 캐시의 주소
+ * @param adminAddress Arcus 클라이언트를 생성하기 위해 필요한 ZooKeeper 주소
* @param serviceCode Arcus 클라이언트를 생성하기 위해 필요한 서비스 코드
* @param connectionFactoryBuilder Arcus 클라이언트를 생성하기 위해 필요한 ConnectionFactory 빌더
* @param poolSize Arcus 클라이언트를 생성하기 위해 필요한 클라이언트 풀 사이즈
* @param defaultConfiguration 정의되지 않은 캐시의 기본 설정
* @param initialCacheConfigs 생성할 캐시들의 이름과 설정들의 집합
*/
- public ArcusCacheManager(
- String adminAddress,
- String serviceCode,
- ConnectionFactoryBuilder connectionFactoryBuilder,
- int poolSize,
- ArcusCacheConfiguration defaultConfiguration,
- Map initialCacheConfigs
- ) {
- this(
- ArcusClient.createArcusClientPool(adminAddress, serviceCode, connectionFactoryBuilder, poolSize),
- defaultConfiguration,
- initialCacheConfigs
- );
+ public ArcusCacheManager(String adminAddress, String serviceCode, ConnectionFactoryBuilder connectionFactoryBuilder,
+ int poolSize, ArcusCacheConfiguration defaultConfiguration,
+ Map initialCacheConfigs) {
+ this.client = ArcusClient.createArcusClientPool(adminAddress, serviceCode, connectionFactoryBuilder, poolSize);
+ this.defaultConfiguration = defaultConfiguration;
+ this.initialCacheConfigs = initialCacheConfigs;
this.internalClient = true;
}
@@ -103,7 +93,7 @@ public static ArcusCacheManagerBuilder builder(String adminAddress,
@Override
protected Collection extends Cache> loadCaches() {
- List caches = new ArrayList(initialCacheConfigs.size());
+ List caches = new ArrayList<>(initialCacheConfigs.size());
for (Map.Entry entry : initialCacheConfigs.entrySet()) {
caches.add(createCache(entry.getKey(), entry.getValue()));
}
diff --git a/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheIntegrationTest.java b/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheIntegrationTest.java
index c28b1a0..7908336 100644
--- a/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheIntegrationTest.java
+++ b/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheIntegrationTest.java
@@ -89,9 +89,7 @@ void throwExceptionIfGetWithDifferentClassType() {
assertNull(arcusCache.get(TEST_KEY));
arcusCache.put(TEST_KEY, TEST_VALUE);
- assertThrows(IllegalStateException.class, () -> {
- arcusCache.get(TEST_KEY, Integer.class);
- });
+ assertThrows(IllegalStateException.class, () -> arcusCache.get(TEST_KEY, Integer.class));
}
@Test
@@ -109,9 +107,7 @@ void throwExceptionIfGetWithValueLoaderFailed() {
};
assertNull(arcusCache.get(TEST_KEY));
- assertThrows(RuntimeException.class, () -> {
- assertEquals(TEST_VALUE, arcusCache.get(TEST_KEY, valueLoader));
- });
+ assertThrows(RuntimeException.class, () -> assertEquals(TEST_VALUE, arcusCache.get(TEST_KEY, valueLoader)));
}
@Test
@@ -163,9 +159,7 @@ void putTheNullValueIfAllowNullValuesIsTrue() {
@Test
void putTheNullValueIfAllowNullValuesIsFalse() {
- assertThrows(IllegalArgumentException.class, () -> {
- arcusCacheWithoutAllowingNullValue.put(TEST_KEY, null);
- });
+ assertThrows(IllegalArgumentException.class, () -> arcusCacheWithoutAllowingNullValue.put(TEST_KEY, null));
}
@Test
diff --git a/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheManagerTest.java b/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheManagerTest.java
index 2ddbde2..0b1803b 100644
--- a/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheManagerTest.java
+++ b/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheManagerTest.java
@@ -126,8 +126,6 @@ void shutdownClientIfArcusClientPoolManagedInCacheManager() throws Exception {
ArcusClientPool client2 = (ArcusClientPool) ReflectionUtils.getField(clientField, this.arcusCacheManagerFromAddress);
assertNotNull(client2);
- assertThrows(IllegalStateException.class, () -> {
- client2.get(key);
- });
+ assertThrows(IllegalStateException.class, () -> client2.get(key));
}
}
diff --git a/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheTest.java b/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheTest.java
index 552d1cc..4abc63f 100644
--- a/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheTest.java
+++ b/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheTest.java
@@ -330,9 +330,7 @@ void throwExceptionIfPutWithWantToGetException() {
.thenThrow(new TestException());
// when
- assertThrows(TestException.class, () -> {
- arcusCache.put(ARCUS_STRING_KEY, VALUE);
- });
+ assertThrows(TestException.class, () -> arcusCache.put(ARCUS_STRING_KEY, VALUE));
}
@Test
@@ -493,9 +491,7 @@ void throwExceptionIfEvictWithWantToGetException() {
.thenThrow(new TestException());
// when
- assertThrows(TestException.class, () -> {
- arcusCache.evict(ARCUS_STRING_KEY);
- });
+ assertThrows(TestException.class, () -> arcusCache.evict(ARCUS_STRING_KEY));
}
@Test
@@ -647,9 +643,7 @@ void clearWithWantToGetException() {
.thenReturn(createOperationFutureException());
// when
- assertThrows(TestException.class, () -> {
- arcusCache.clear();
- });
+ assertThrows(TestException.class, () -> arcusCache.clear());
}
@Test
@@ -806,9 +800,7 @@ void getWithDifferentClassType() {
.thenReturn(createGetFuture(VALUE));
// when
- assertThrows(IllegalStateException.class, () -> {
- arcusCache.get(ARCUS_STRING_KEY, Integer.class);
- });
+ assertThrows(IllegalStateException.class, () -> arcusCache.get(ARCUS_STRING_KEY, Integer.class));
}
@Test
@@ -819,9 +811,7 @@ void throwExceptionIfGetWithClassTypeWithWantToGetException() {
.thenThrow(new TestException());
// when
- assertThrows(TestException.class, () -> {
- arcusCache.get(ARCUS_STRING_KEY, String.class);
- });
+ assertThrows(TestException.class, () -> arcusCache.get(ARCUS_STRING_KEY, String.class));
}
@Test
@@ -832,9 +822,7 @@ void throwExceptionIfGetWithClassTypeHasFutureExceptionWithWantToGetException()
.thenReturn(createGetFutureException());
// when
- assertThrows(TestException.class, () -> {
- arcusCache.get(ARCUS_STRING_KEY, String.class);
- });
+ assertThrows(TestException.class, () -> arcusCache.get(ARCUS_STRING_KEY, String.class));
}
@Test
diff --git a/src/test/java/com/navercorp/arcus/spring/cache/front/DefaultArcusFrontCacheTest.java b/src/test/java/com/navercorp/arcus/spring/cache/front/DefaultArcusFrontCacheTest.java
index 8a06b0f..9757c86 100644
--- a/src/test/java/com/navercorp/arcus/spring/cache/front/DefaultArcusFrontCacheTest.java
+++ b/src/test/java/com/navercorp/arcus/spring/cache/front/DefaultArcusFrontCacheTest.java
@@ -42,9 +42,7 @@ void after() {
@Test
void frontCacheNameConflict() {
new DefaultArcusFrontCache("test", 3L, false, false);
- assertThrows(ObjectExistsException.class, () -> {
- new DefaultArcusFrontCache("test", 3L, false, false);
- });
+ assertThrows(ObjectExistsException.class, () -> new DefaultArcusFrontCache("test", 3L, false, false));
}
@Test
diff --git a/src/test/java/com/navercorp/arcus/spring/concurrent/DefaultKeyLockProviderTest.java b/src/test/java/com/navercorp/arcus/spring/concurrent/DefaultKeyLockProviderTest.java
index 1b9bd1e..a44d521 100644
--- a/src/test/java/com/navercorp/arcus/spring/concurrent/DefaultKeyLockProviderTest.java
+++ b/src/test/java/com/navercorp/arcus/spring/concurrent/DefaultKeyLockProviderTest.java
@@ -30,7 +30,7 @@ class DefaultKeyLockProviderTest {
@Test
void doNotThrowArrayIndexOufOfBoundsException() {
- Set hashCodeSet = new HashSet();
+ Set hashCodeSet = new HashSet<>();
int exponentOfLocks = DefaultKeyLockProvider.DEFAULT_EXPONENT_OF_LOCKS + 1;
int numberOfLocks = (int) Math.pow(2, exponentOfLocks);
@@ -51,14 +51,11 @@ void doNotAllowConcurrentAccessIfUsingKeyLockProvider() throws InterruptedExcept
final DefaultKeyLockProvider provider = new DefaultKeyLockProvider();
final TestObject key = new TestObject(0);
final int maxCount = 10000;
- final Runnable runnable = new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < maxCount; i++) {
- provider.getLockForKey(key).writeLock().lock();
- count++;
- provider.getLockForKey(key).writeLock().unlock();
- }
+ final Runnable runnable = () -> {
+ for (int i = 0; i < maxCount; i++) {
+ provider.getLockForKey(key).writeLock().lock();
+ count++;
+ provider.getLockForKey(key).writeLock().unlock();
}
};
diff --git a/src/test/resources/log4j2.properties b/src/test/resources/log4j2.properties
index 237d56a..ee4f1b9 100644
--- a/src/test/resources/log4j2.properties
+++ b/src/test/resources/log4j2.properties
@@ -2,7 +2,7 @@ log4j.appender.console.type=Console
log4j.appender.console.layout.type=PatternLayout
log4j.appender.console.layout.pattern=%-5p: %c - %m%n
-log4j.rootLogger.level=INFO,console
+log4j.rootLogger.level=INFO,console
log4j.loggers=arcus,spring