From a72e25a789e7b2530ac3bf67a665761f8e89e7f8 Mon Sep 17 00:00:00 2001 From: seojin Yoon <90759319+7zrv@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:47:34 +0900 Subject: [PATCH 1/2] =?UTF-8?q?style(loggingaspect):=20=EC=A1=B0=EA=B1=B4?= =?UTF-8?q?=EB=AC=B8=EC=9D=98=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - maskSensitiveData의 else if를 이용했던 분기문을 각각의 if문으로 분 --- .../global/aspect/log/utils/SensitiveDataMasker.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/somemore/global/aspect/log/utils/SensitiveDataMasker.java b/src/main/java/com/somemore/global/aspect/log/utils/SensitiveDataMasker.java index 6addf11f..69b02067 100644 --- a/src/main/java/com/somemore/global/aspect/log/utils/SensitiveDataMasker.java +++ b/src/main/java/com/somemore/global/aspect/log/utils/SensitiveDataMasker.java @@ -19,9 +19,11 @@ public class SensitiveDataMasker { public Object maskSensitiveData(String fieldName, Object value, ObjectMapper objectMapper) throws JsonProcessingException { if (isSensitiveField(fieldName)) { return "********"; - } else if (value instanceof Map) { + } + if (value instanceof Map) { return maskSensitiveDataInMap((Map) value); - } else if (isComplexObject(value)) { + } + if (isComplexObject(value)) { String json = objectMapper.writeValueAsString(value); json = maskSensitiveDataInJson(json, objectMapper); return objectMapper.readValue(json, Object.class); From 70edeec0f7d7765fb7849029e03c298b316f6a3d Mon Sep 17 00:00:00 2001 From: seojin Yoon <90759319+7zrv@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:59:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20ObjectMapper=20=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EC=8B=9C=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20unchecked=20?= =?UTF-8?q?=EA=B2=BD=EA=B3=A0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TypeReference>를 사용하여 JSON 역직렬화 과정에서 발생하는 경고를 제거 --- .../somemore/global/aspect/log/utils/SensitiveDataMasker.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/somemore/global/aspect/log/utils/SensitiveDataMasker.java b/src/main/java/com/somemore/global/aspect/log/utils/SensitiveDataMasker.java index 69b02067..9b8b870d 100644 --- a/src/main/java/com/somemore/global/aspect/log/utils/SensitiveDataMasker.java +++ b/src/main/java/com/somemore/global/aspect/log/utils/SensitiveDataMasker.java @@ -1,6 +1,7 @@ package com.somemore.global.aspect.log.utils; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -56,7 +57,7 @@ private Map maskSensitiveDataInMap(Map map) { private String maskSensitiveDataInJson(String json, ObjectMapper objectMapper) { try { - Map jsonMap = objectMapper.readValue(json, Map.class); + Map jsonMap = objectMapper.readValue(json, new TypeReference<>() {}); Map maskedMap = maskSensitiveDataInMap(jsonMap); return objectMapper.writeValueAsString(maskedMap); } catch (Exception e) {