From 7716705fe31c91f696d3de1898f81e87093549d2 Mon Sep 17 00:00:00 2001 From: Jeff Zhu Date: Fri, 27 Jul 2018 11:43:08 +0800 Subject: [PATCH] #448 code review update --- .../service/impl/SystemConfigServiceImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/saturn-console-api/src/main/java/com/vip/saturn/job/console/service/impl/SystemConfigServiceImpl.java b/saturn-console-api/src/main/java/com/vip/saturn/job/console/service/impl/SystemConfigServiceImpl.java index 9db4bafc9..b21b674c6 100644 --- a/saturn-console-api/src/main/java/com/vip/saturn/job/console/service/impl/SystemConfigServiceImpl.java +++ b/saturn-console-api/src/main/java/com/vip/saturn/job/console/service/impl/SystemConfigServiceImpl.java @@ -202,11 +202,13 @@ public Integer createConfig(SystemConfig systemConfig) throws SaturnJobConsoleEx List systemConfigs = systemConfig4SqlService.selectByProperty(systemConfig.getProperty()); boolean found = false; - for (int i = 0; i < systemConfigs.size(); i++) { - SystemConfig config = systemConfigs.get(i); - if (StringUtils.equals(config.getProperty(), systemConfig.getProperty())) { - found = true; - break; + if (systemConfigs != null) { + for (int i = 0; i < systemConfigs.size(); i++) { + SystemConfig config = systemConfigs.get(i); + if (StringUtils.equals(config.getProperty(), systemConfig.getProperty())) { + found = true; + break; + } } } @@ -226,7 +228,7 @@ public Integer updateConfig(SystemConfig systemConfig) throws SaturnJobConsoleEx properties.add(systemConfig.getProperty()); List systemConfigs = systemConfig4SqlService.selectByPropertiesAndLastly(properties); - if (systemConfigs.size() == 0) { + if (systemConfigs == null || systemConfigs.isEmpty()) { throw new SaturnJobConsoleException( String.format("systemConfig %s not existed, update fail", systemConfig.getProperty())); }