From eca9fd100c44b220b9f76d034b04c80f7aea9924 Mon Sep 17 00:00:00 2001 From: Timmy Date: Fri, 6 Dec 2019 15:27:16 +0800 Subject: [PATCH] [fix bug ] fix @TarsClient annotation parsing is incorrect --- .../com/qq/tars/client/ServantProxyConfig.java | 15 ++++++++++++--- .../bean/CommunicatorBeanPostProcessor.java | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/qq/tars/client/ServantProxyConfig.java b/core/src/main/java/com/qq/tars/client/ServantProxyConfig.java index 6766a989..0476ab18 100644 --- a/core/src/main/java/com/qq/tars/client/ServantProxyConfig.java +++ b/core/src/main/java/com/qq/tars/client/ServantProxyConfig.java @@ -196,11 +196,20 @@ public String getSetDivision() { } public void setSetDivision(String setDivision) { + if (StringUtils.isEmpty(setDivision)) { + return; + } this.setDivision = setDivision; String[] tmp = StringUtils.split(setDivision, "."); - this.slaveSetName = tmp[0]; - this.slaveSetArea = tmp[1]; - this.slaveSetID = tmp[2]; + if (tmp.length >= 3) { + this.slaveSetName = tmp[0]; + this.slaveSetArea = tmp[1]; + this.slaveSetID = tmp[2]; + } else { + this.slaveName = ""; + this.slaveSetArea = ""; + this.slaveSetID = ""; + } this.updateSlaveName(); } diff --git a/spring/tars-spring-boot-starter/src/main/java/com/qq/tars/spring/bean/CommunicatorBeanPostProcessor.java b/spring/tars-spring-boot-starter/src/main/java/com/qq/tars/spring/bean/CommunicatorBeanPostProcessor.java index d2a5aff9..b41c02bf 100644 --- a/spring/tars-spring-boot-starter/src/main/java/com/qq/tars/spring/bean/CommunicatorBeanPostProcessor.java +++ b/spring/tars-spring-boot-starter/src/main/java/com/qq/tars/spring/bean/CommunicatorBeanPostProcessor.java @@ -69,10 +69,10 @@ private void processFields(Object bean, Field[] declaredFields) { ServantProxyConfig config = new ServantProxyConfig(objName); CommunicatorConfig communicatorConfig = ConfigurationManager.getInstance().getServerConfig().getCommunicatorConfig(); config.setModuleName(communicatorConfig.getModuleName(), communicatorConfig.isEnableSet(), communicatorConfig.getSetDivision()); - if (annotation.setDivision() != null) { + if (StringUtils.isNotEmpty(annotation.setDivision())) { config.setEnableSet(true); + config.setSetDivision(annotation.setDivision()); } - config.setSetDivision(annotation.setDivision()); config.setConnections(annotation.connections()); config.setConnectTimeout(annotation.connectTimeout()); config.setSyncTimeout(annotation.syncTimeout());