TyrantLucifer commented on code in PR #3511:
URL:
https://github.com/apache/incubator-seatunnel/pull/3511#discussion_r1029485373
##########
seatunnel-connectors-v2/connector-socket/src/main/java/org/apache/seatunnel/connectors/seatunnel/socket/sink/SocketClient.java:
##########
@@ -70,37 +73,22 @@ public void write(SeaTunnelRow row) throws IOException {
try {
outputStream.write(msg);
outputStream.flush();
-
} catch (IOException e) {
// if no re-tries are enable, fail immediately
if (maxNumRetries == 0) {
- throw new IOException(
- "Failed to send message '"
- + row
- + "' to socket server at "
- + hostName
- + ":"
- + port
- + ". Connection re-tries are not enabled.",
- e);
+ throw new IOException(String.format(
Review Comment:
The same as above, you can define a new error code.
##########
seatunnel-connectors-v2/connector-socket/src/main/java/org/apache/seatunnel/connectors/seatunnel/socket/sink/SocketClient.java:
##########
@@ -128,32 +116,21 @@ public void write(SeaTunnelRow row) throws IOException {
} catch (IOException ee) {
lastException = ee;
log.error(
- "Re-connect to socket server and send message
failed. Retry time(s): "
- + retries,
- ee);
+ "Re-connect to socket server and send message
failed. Retry time(s): {}",
+ retries, ee);
}
try {
this.wait(CONNECTION_RETRY_DELAY);
- }
- catch (InterruptedException ex) {
+ } catch (InterruptedException ex) {
Thread.currentThread().interrupt();
- throw new IOException(
- "unable to write; interrupted while doing
another attempt", e);
+ throw new IOException("unable to write; interrupted
while doing another attempt", e);
Review Comment:
The same as above.
##########
seatunnel-connectors-v2/connector-socket/src/main/java/org/apache/seatunnel/connectors/seatunnel/socket/sink/SocketClient.java:
##########
@@ -61,7 +62,9 @@ public void open() throws IOException {
createConnection();
}
} catch (IOException e) {
- throw new IOException("Cannot connect to socket server at " +
hostName + ":" + port, e);
+ throw new IOException(String.format(
+ "Cannot connect to socket server at %s:%d",
+ hostName, port), e);
Review Comment:
```suggestion
throw new
SocketConnectorException(SocketErrorCode.SOCKET_SERVER_CONNECT_FAILED,
String.format(
"Cannot connect to socket server at %s:%d",
hostName, port), e);
```
##########
seatunnel-connectors-v2/connector-socket/src/main/java/org/apache/seatunnel/connectors/seatunnel/socket/sink/SocketClient.java:
##########
@@ -128,32 +116,21 @@ public void write(SeaTunnelRow row) throws IOException {
} catch (IOException ee) {
lastException = ee;
log.error(
- "Re-connect to socket server and send message
failed. Retry time(s): "
- + retries,
- ee);
+ "Re-connect to socket server and send message
failed. Retry time(s): {}",
+ retries, ee);
}
try {
this.wait(CONNECTION_RETRY_DELAY);
- }
- catch (InterruptedException ex) {
+ } catch (InterruptedException ex) {
Thread.currentThread().interrupt();
- throw new IOException(
- "unable to write; interrupted while doing
another attempt", e);
+ throw new IOException("unable to write; interrupted
while doing another attempt", e);
}
}
if (isRunning) {
- throw new IOException(
- "Failed to send message '"
- + row
- + "' to socket server at "
- + hostName
- + ":"
- + port
- + ". Failed after "
- + retries
- + " retries.",
- lastException);
+ throw new IOException(String.format(
Review Comment:
The same as above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]