From 241a37978dc70cbbcf99c413a1e097de6d90e70e Mon Sep 17 00:00:00 2001 From: uhm0311 Date: Fri, 14 Jun 2024 18:20:20 +0900 Subject: [PATCH] INTERNAL: Log info level when null value is present to ArcusCache.putIfAbsent() method. --- .../java/com/navercorp/arcus/spring/cache/ArcusCache.java | 3 ++- .../java/com/navercorp/arcus/spring/cache/ArcusCacheTest.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) 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 fbfc248..3d32db8 100644 --- a/src/main/java/com/navercorp/arcus/spring/cache/ArcusCache.java +++ b/src/main/java/com/navercorp/arcus/spring/cache/ArcusCache.java @@ -217,7 +217,8 @@ public ValueWrapper putIfAbsent(Object key, Object value) { logger.debug("trying to add key: {}", arcusKey); if (value == null) { - throw new IllegalArgumentException("arcus cannot add NULL value. key: " + arcusKey); + logger.info("arcus cannot putIfAbsent NULL value. key: {}", arcusKey); + return null; } try { 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 df582d9..4ce204b 100644 --- a/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheTest.java +++ b/src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheTest.java @@ -1306,12 +1306,14 @@ public void testPutIfAbsent_FrontCache_FutureException_ForceFrontCaching() { } @Test + @SuppressWarnings("deprecation") public void testPutIfAbsent_FrontCache_Null() { // given IllegalArgumentException exception = null; arcusCache.setArcusFrontCache(arcusFrontCache); arcusCache.setExpireSeconds(EXPIRE_SECONDS); arcusCache.setFrontExpireSeconds(FRONT_EXPIRE_SECONDS); + arcusCache.setWantToGetException(true); when(arcusClientPool.add(arcusKey, EXPIRE_SECONDS, VALUE)) .thenReturn(createOperationFuture(true)); when(arcusClientPool.asyncGet(arcusKey)) @@ -1331,7 +1333,7 @@ public void testPutIfAbsent_FrontCache_Null() { .asyncGet(arcusKey); verify(arcusFrontCache, never()) .set(arcusKey, VALUE, FRONT_EXPIRE_SECONDS); - assertNotNull(exception); + assertNull(exception); } private static GetFuture createGetFuture(