From 5273b81f949517bc00a9bbb9ad9a87494ba0eb99 Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Mon, 17 Jul 2023 16:11:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90issues/5115=E3=80=91=E5=9B=A0swagger?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=AF=BC=E8=87=B4gateway=E5=86=85=E5=AD=98?= =?UTF-8?q?=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/swagger/MySwaggerResourceProvider.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jeecg-server-cloud/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/MySwaggerResourceProvider.java b/jeecg-server-cloud/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/MySwaggerResourceProvider.java index bce7b5f1..d4e81d76 100644 --- a/jeecg-server-cloud/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/MySwaggerResourceProvider.java +++ b/jeecg-server-cloud/jeecg-cloud-gateway/src/main/java/org/jeecg/handler/swagger/MySwaggerResourceProvider.java @@ -35,6 +35,10 @@ public class MySwaggerResourceProvider implements SwaggerResourcesProvider { * 网关路由 */ private final RouteLocator routeLocator; + /** + * Nacos名字服务 + */ + private NamingService naming; /** * nacos服务地址 @@ -115,9 +119,12 @@ public class MySwaggerResourceProvider implements SwaggerResourcesProvider { if(namespace!=null && !"".equals(namespace)){ properties.setProperty("namespace",namespace); } - NamingService naming = NamingFactory.createNamingService(properties); + //【issues/5115】因swagger文档导致gateway内存溢出 + if (this.naming == null) { + this.naming = NamingFactory.createNamingService(properties); + } - List list = naming.selectInstances(routeId, true); + List list = this.naming.selectInstances(routeId, true); if (ObjectUtil.isNotEmpty(list)) { hasRoute = true; }