sandynz commented on code in PR #22740:
URL: https://github.com/apache/shardingsphere/pull/22740#discussion_r1042968895


##########
kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java:
##########
@@ -270,6 +280,10 @@ private final class MySQLBinlogEventHandler extends 
ChannelInboundHandlerAdapter
         
         private AbstractBinlogEvent lastBinlogEvent;

Review Comment:
   Could `lastBinlogEvent` be final and simplify constructor?



##########
kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/PasswordEncryption.java:
##########
@@ -107,7 +107,7 @@ private static RSAPublicKey parseRSAPublicKey(final String 
key) throws GeneralSe
     
     private static byte[] formatKey(final String key) {
         int start = key.indexOf("\n") + 1;
-        int end = key.lastIndexOf("\n");
+        int end = key.endsWith("\n") ? key.substring(0, key.length() - 
2).lastIndexOf("\n") : key.lastIndexOf("\n");
         return key.substring(start, end).replace("\n", "").getBytes();

Review Comment:
   1, When it needs RSA?
   
   2, Could we just use `key.trim()` to replace `key.substring(start, end)`?
   



##########
kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java:
##########
@@ -157,6 +158,7 @@ public synchronized void subscribe(final String 
binlogFileName, final long binlo
         dumpBinlog(binlogFileName, binlogPosition, queryChecksumLength());
         log.info("subscribe binlog file: {}, position: {}", binlogFileName, 
binlogPosition);
         reconnectTimes.set(0);
+        running = true;

Review Comment:
   Could we put `reconnectTimes` and `running` reset logic to `connect` method 
instead of `subscribe` method?
   Since they're related to connection but not subscription.



-- 
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]

Reply via email to