From d6c9974065e8973bd771b68259c90be86fba73e9 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Tue, 13 Jul 2021 16:53:53 +0800 Subject: [PATCH] =?UTF-8?q?chore(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A3=80=E6=9F=A5kafka=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=AF=BC=E8=87=B4=E7=9A=84kafka=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PerformanceTestService.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 8166327466..a2c8447910 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -45,7 +45,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.File; import java.io.IOException; -import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.nio.charset.StandardCharsets; @@ -318,15 +317,11 @@ public class PerformanceTestService { //1,建立tcp String ip = ipAndPort[0]; int port = Integer.parseInt(ipAndPort[1]); - Socket soc = new Socket(); - soc.connect(new InetSocketAddress(ip, port), 1000); // 1s timeout - //2.输入内容 - String content = "1010"; - byte[] bs = content.getBytes(); - OutputStream os = soc.getOutputStream(); - os.write(bs); - //3.关闭 - soc.close(); + try ( + Socket soc = new Socket(); + ) { + soc.connect(new InetSocketAddress(ip, port), 1000); // 1s timeout + } } } catch (Exception e) { LogUtil.error(e.getMessage(), e);