From b95ce0a2217120151b210ed6bd8cf4281b7d53c4 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 16 Apr 2021 17:09:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20service=20=E5=8C=BA=E5=88=86=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/consul/CatalogApiController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/consul/CatalogApiController.java b/backend/src/main/java/io/metersphere/consul/CatalogApiController.java index 4611f83ece..50aa2519eb 100644 --- a/backend/src/main/java/io/metersphere/consul/CatalogApiController.java +++ b/backend/src/main/java/io/metersphere/consul/CatalogApiController.java @@ -80,7 +80,9 @@ public class CatalogApiController { .body(JSON.parseArray("[]")); } - String[] ipAndPort = service.split("-"); + int i = service.lastIndexOf("-"); + String address = service.substring(0, i); + String port = service.substring(i); String result = "[\n" + " {\n" + " \"Node\": {\n" + @@ -106,9 +108,9 @@ public class CatalogApiController { " \"Tags\": [\n" + " \"test\"\n" + " ],\n" + - " \"Address\": \"" + ipAndPort[0] + "\",\n" + + " \"Address\": \"" + address + "\",\n" + " \"Meta\": null,\n" + - " \"Port\": " + ipAndPort[1] + ",\n" + + " \"Port\": " + port + ",\n" + " \"Weights\": {\n" + " \"Passing\": 1,\n" + " \"Warning\": 1\n" +