TyrantLucifer commented on code in PR #2483:
URL: 
https://github.com/apache/incubator-seatunnel/pull/2483#discussion_r950812133


##########
seatunnel-connectors-v2/connector-file/connector-file-ftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/ftp/util/FtpFileUtils.java:
##########
@@ -33,37 +34,45 @@
 
 public class FtpFileUtils {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(FtpFileUtils.class);
-    public  static FTPClient FTPCLIENT;
+    public static FTPClient FTPCLIENT;
     public static  String FTP_PASSWORD;
     public static  String FTP_USERNAME;
     public static  String FTP_HOST;
     public static  Integer FTP_PORT;
     public static final int FTP_CONNECT_MAX_TIMEOUT = 30000;
 
     public static FTPClient getFTPClient(){
-        return getFTPClient(FTP_HOST, FTP_PORT, FTP_USERNAME, FTP_PASSWORD);
+        if (StringUtils.isBlank(FTP_HOST) || StringUtils.isBlank(FTP_USERNAME) 
|| StringUtils.isBlank(FTP_PASSWORD) || 
StringUtils.isBlank(FTP_PORT.toString())) {

Review Comment:
   Because your `FTP_PASSWORD` is public, so everyone can change this attribute 
to `NULL`. So it's possibly return null for your code. And I think use these 
four attribute to judge FTPCLIENT is or not existed not suitable. You should 
ensure that your singleton pattern is globally thread-safe.



##########
seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/BaseFileSourceReader.java:
##########
@@ -37,7 +37,7 @@ public class BaseFileSourceReader implements 
SourceReader<SeaTunnelRow, FileSour
     private final Context context;

Review Comment:
   Please keep this file change out of your submission, give you a advice, you 
can revert this file and keep this file the same as dev branch.



##########
seatunnel-connectors-v2/connector-file/connector-file-ftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/ftp/FtpFileSink.java:
##########
@@ -39,11 +45,19 @@ public SinkFileSystemPlugin getSinkFileSystemPlugin() {
     public void prepare(Config pluginConfig) throws PrepareFailException {
 
         super.prepare(pluginConfig);
-        FtpFileUtils.FTP_HOST = 
String.valueOf(pluginConfig.getString("ftp_host"));
-        FtpFileUtils.FTP_USERNAME = 
String.valueOf(pluginConfig.getString("ftp_username"));
-        FtpFileUtils.FTP_PASSWORD = 
String.valueOf(pluginConfig.getString("ftp_password"));
-        FtpFileUtils.FTP_PORT = pluginConfig.getInt("ftp_port");
 
-        FtpFileUtils.getFTPClient();
+        if (pluginConfig.hasPath(FtpConfig.FTP_HOST)) {

Review Comment:
   I think these parameters are required for your connector, you should add 
check logic for these parameters. If user do not  config these parameters you 
should throw RuntimeExecption.



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