ruanhang1993 commented on code in PR #4156:
URL: https://github.com/apache/flink-cdc/pull/4156#discussion_r2450316899


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/debezium/DebeziumUtilsTest.java:
##########
@@ -83,6 +89,26 @@ private MySqlSourceConfig getConfig(Properties 
jdbcProperties) {
                 .createConfig(0);
     }
 
+    @ParameterizedTest
+    @MethodSource("sslModeProvider")
+    void testSslModeConversion(MySqlConnectorConfig.SecureConnectionMode 
input, SSLMode expected) {

Review Comment:
   @watsonjo737 Could you add a test for mysql cdc source in Flink SQL about 
how to use ssl mode?



##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/debezium/DebeziumUtils.java:
##########
@@ -242,12 +243,23 @@ private static Map<String, String> querySystemVariables(
         return variables;
     }
 
+    static SSLMode sslModeFor(MySqlConnectorConfig.SecureConnectionMode mode) {
+        try {
+            return mode == null ? null : SSLMode.valueOf(mode.name());
+        } catch (IllegalArgumentException e) {
+            LOG.error("Invalid SecureConnectionMode provided %s", mode.name(), 
e);
+        }
+        return null;
+    }
+
     public static BinlogOffset findBinlogOffset(
             long targetMs, MySqlConnection connection, MySqlSourceConfig 
mySqlSourceConfig) {
         MySqlConnection.MySqlConnectionConfiguration config = 
connection.connectionConfig();
         BinaryLogClient client =
                 new BinaryLogClient(
                         config.hostname(), config.port(), config.username(), 
config.password());
+        client.setSSLMode(sslModeFor(config.sslMode()));

Review Comment:
   If sslMode is null, method `setSSLMode` will throw an exception.
   It is better to change as following:
   ```java
   if (sslMode != null) {
     client.setSSLMode(sslMode);
   }
   ```



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