From 64fd0176aca1e22039a5d4d478ee9db5f06fc865 Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Thu, 22 Nov 2018 14:45:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=89=8B=E5=8A=A8new=20XXXSe?= =?UTF-8?q?rvice=E5=AD=97=E6=AE=B5inject=E6=97=B6=E6=8A=9B=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/org/redkale/boot/NodeServer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/org/redkale/boot/NodeServer.java b/src/org/redkale/boot/NodeServer.java index af76306bb..c2018172a 100644 --- a/src/org/redkale/boot/NodeServer.java +++ b/src/org/redkale/boot/NodeServer.java @@ -240,7 +240,11 @@ public abstract class NodeServer { } if (DataSource.class.isAssignableFrom(sourceType) && can) { // 必须有空构造函数 final Service srcService = (Service) src; - SncpClient client = Sncp.getSncpClient(srcService); + SncpClient client = null; + try { + client = Sncp.getSncpClient(srcService); + } catch (RuntimeException re) { + } final InetSocketAddress sncpAddr = client == null ? null : client.getClientAddress(); final Set groups = new HashSet<>(); if (client != null && client.getSameGroup() != null) groups.add(client.getSameGroup()); @@ -255,7 +259,11 @@ public abstract class NodeServer { application.dataSources.add(source); appResFactory.register(resourceName, DataSource.class, source); - SncpClient client = Sncp.getSncpClient((Service) src); + SncpClient client = null; + try { //Service成员变量是一个直接new XXXService的字段, 递归ResourceFactory.inject时会导致找不到SncpClient + client = Sncp.getSncpClient((Service) src); + } catch (RuntimeException re) { + } final InetSocketAddress sncpAddr = client == null ? null : client.getClientAddress(); if ((src instanceof DataSource) && sncpAddr != null && resourceFactory.find(resourceName, DataCacheListener.class) == null) { //只有DataSourceService 才能赋值 DataCacheListener final NodeSncpServer sncpServer = application.findNodeSncpServer(sncpAddr);