Skip to content

Commit 166282b

Browse files
committed
fix: netutil clear socket read
1 parent f862821 commit 166282b

File tree

1 file changed

+2
-17
lines changed
  • connectors-common/connector-core/src/main/java/io/tapdata/util

1 file changed

+2
-17
lines changed

connectors-common/connector-core/src/main/java/io/tapdata/util/NetUtil.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import io.tapdata.kit.EmptyKit;
44

5-
import java.io.*;
5+
import java.io.IOException;
66
import java.net.InetSocketAddress;
77
import java.net.Socket;
88

@@ -30,24 +30,9 @@ public static void validateHostPortWithSocket(String host, int port, int timeout
3030
throw new IllegalArgumentException("Port must greater than 0 and smaller then 65536");
3131
timeoutMs = timeoutMs <= 1000 ? DEFAULT_SOCKET_TIMEOUT_MS : timeoutMs;
3232
try (Socket s = new Socket()) {
33-
if (port == 0) {
34-
return;
35-
} else {
33+
if (port > 0) {
3634
s.connect(new InetSocketAddress(host, port), timeoutMs);
3735
}
38-
s.setSoTimeout(3000);
39-
try (
40-
InputStream in = s.getInputStream();
41-
OutputStream out = s.getOutputStream()
42-
) {
43-
String request = "GET / HTTP/1.1\r\nHost: " + host + "\r\n\r\n";
44-
out.write(request.getBytes());
45-
out.flush();
46-
47-
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
48-
reader.readLine();
49-
}
50-
}
5136
} catch (IOException e) {
5237
throw new IOException("Unable connect to " + host + ":" + port + ", reason: " + e.getMessage(), e);
5338
}

0 commit comments

Comments
 (0)