From adf1fd63fb7989993458014b542d4b5fc1318e32 Mon Sep 17 00:00:00 2001 From: Rinjae Date: Wed, 10 Dec 2025 21:27:11 +0900 Subject: [PATCH] =?UTF-8?q?kjbproperty=20=EB=A1=9C=EB=94=A9=20=EC=88=9C?= =?UTF-8?q?=EC=84=9C=20=EB=B0=8F=20NPE=20=EB=AC=B8=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MonitoringPropertyService.java | 11 ++++--- .../service/ums/UmsDispatchService.java | 22 +++++-------- .../ext/kjb/util/KjbPropertyInjector.java | 31 ++++++++++++++----- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/eactive/eai/rms/data/entity/man/monitoringProperty/service/MonitoringPropertyService.java b/src/main/java/com/eactive/eai/rms/data/entity/man/monitoringProperty/service/MonitoringPropertyService.java index bbd3e0d..02791b6 100644 --- a/src/main/java/com/eactive/eai/rms/data/entity/man/monitoringProperty/service/MonitoringPropertyService.java +++ b/src/main/java/com/eactive/eai/rms/data/entity/man/monitoringProperty/service/MonitoringPropertyService.java @@ -41,12 +41,13 @@ public class MonitoringPropertyService id.setPrptyName(prptyName); Optional property = repository.findById(id); - if (property.isPresent() && !property.get().getPrpty2Val().isEmpty()) { - return property.get().getPrpty2Val(); - } else { - return defaultValue; + if (property.isPresent()) { + String value = property.get().getPrpty2Val(); + if (value != null && !value.isEmpty()) { + return value; + } } - + return defaultValue; } public Iterable findAllByIdPrptyName(String prptyName) { diff --git a/src/main/java/com/eactive/eai/rms/onl/common/service/ums/UmsDispatchService.java b/src/main/java/com/eactive/eai/rms/onl/common/service/ums/UmsDispatchService.java index 5211520..5b30d91 100644 --- a/src/main/java/com/eactive/eai/rms/onl/common/service/ums/UmsDispatchService.java +++ b/src/main/java/com/eactive/eai/rms/onl/common/service/ums/UmsDispatchService.java @@ -17,13 +17,14 @@ import org.springframework.transaction.support.TransactionTemplate; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import java.io.IOException; import java.time.LocalDateTime; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import javax.annotation.PostConstruct; + @Slf4j @Service @@ -55,11 +56,7 @@ public class UmsDispatchService { MessageRequestRepository messageRequestRepository ) { this.kjbPropertyInjector = new KjbPropertyInjector(monitoringPropertyService, PROP_GORUP_ID); - this.messageRequestRepository = messageRequestRepository; -// this.kjbEmailService = kjbEmailService; -// this.kjbSafedbWrapper = kjbSafedbWrapper; -// this.monitoringPropertyService = monitoringPropertyService; this.executorService = new ThreadPoolExecutor( CORE_POOL_SIZE, @@ -72,21 +69,16 @@ public class UmsDispatchService { this.transactionTemplate = new TransactionTemplate(transactionManager); log.debug("UmsDispatchService initialized with thread pool - core: {}, max: {}, queue: {}", CORE_POOL_SIZE, MAX_POOL_SIZE, QUEUE_CAPACITY); + } - - KjbProperty prop = new KjbProperty(); -// prop.setEaiBatchUrl(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.url")); -// prop.setUmsEaiBatchSendDir(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.send_dir")); -// prop.setUmsEaiBatchBackupDir(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.backup_dir")); -// prop.setUmsEaiBatchInterfaceId(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.interface_id")); -// prop.setUmsHostUrl(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.host_url")); -// prop.setUmsApiKey(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.api_key")); - prop = kjbPropertyInjector.inject(prop); + @PostConstruct + public void init() { + KjbProperty prop = kjbPropertyInjector.inject(new KjbProperty()); try { this.kjbUmsService = new KjbUmsService(prop); - this.kjbEmailSendModule = KjbEmailSendModule.getInstance(prop, messageRequestRepository); + log.info("KjbUmsService and KjbEmailSendModule initialized successfully"); } catch (Exception e) { log.error("Failed to initialize KjbUmsService or KjbEmailSendModule: {}", e.getMessage(), e); } diff --git a/src/main/java/com/eactive/ext/kjb/util/KjbPropertyInjector.java b/src/main/java/com/eactive/ext/kjb/util/KjbPropertyInjector.java index 8b4ac6c..d0074e5 100644 --- a/src/main/java/com/eactive/ext/kjb/util/KjbPropertyInjector.java +++ b/src/main/java/com/eactive/ext/kjb/util/KjbPropertyInjector.java @@ -30,6 +30,11 @@ public class KjbPropertyInjector { String rawValue = monitoringPropertyService.getPropertyValue(groupId, key, anno.defaultValue()); Object convertedValue = convertValue(field.getType(), rawValue); + // null이면 필드의 기본값 유지 (primitive 타입에 null 할당 방지) + if (convertedValue == null) { + continue; + } + field.setAccessible(true); try { field.set(property, convertedValue); @@ -46,16 +51,26 @@ public class KjbPropertyInjector { private static Object convertValue(Class type, String rawValue) { if (rawValue == null) return null; - if (StringUtils.isEmpty(rawValue)) return ""; if (type == String.class) return rawValue; - if (type == Integer.class || type == int.class) return Integer.valueOf(rawValue); - if (type == Long.class || type == long.class) return Long.valueOf(rawValue); - if (type == Double.class || type == double.class) return Double.valueOf(rawValue); - if (type == Boolean.class || type == boolean.class) return Boolean.valueOf(rawValue); - if (type == Float.class || type == float.class) return Float.valueOf(rawValue); - if (type == Short.class || type == short.class) return Short.valueOf(rawValue); - if (type == Byte.class || type == byte.class) return Byte.valueOf(rawValue); + + // 빈 문자열인 경우 primitive 타입은 null 반환 (필드의 기본값 유지) + if (StringUtils.isEmpty(rawValue)) { + return null; + } + + try { + if (type == Integer.class || type == int.class) return Integer.valueOf(rawValue); + if (type == Long.class || type == long.class) return Long.valueOf(rawValue); + if (type == Double.class || type == double.class) return Double.valueOf(rawValue); + if (type == Boolean.class || type == boolean.class) return Boolean.valueOf(rawValue); + if (type == Float.class || type == float.class) return Float.valueOf(rawValue); + if (type == Short.class || type == short.class) return Short.valueOf(rawValue); + if (type == Byte.class || type == byte.class) return Byte.valueOf(rawValue); + } catch (NumberFormatException e) { + log.warn("Failed to convert value '{}' to type {}, returning null", rawValue, type.getSimpleName()); + return null; + } return rawValue; }