public static FtpTimeout parseTimeout()

in deploy-runner-agent/src/main/java/jetbrains/buildServer/deployer/agent/ftp/FtpTimeout.java [16:46]


    public static FtpTimeout parseTimeout(BuildRunnerContext context) {
        FtpTimeout fct = new FtpTimeout();
        String timeout = context.getBuild().getSharedConfigParameters().get(FTPRunnerConstants.PARAM_FTP_CONNECT_TIMEOUT);
        if (timeout != null && timeout.isEmpty()) {
            String[] timeouts = timeout.split(" ");
            try {
                if (timeouts.length == 1) {
                    fct.setAllTimeout(getTimeoutFromString(timeout, DEFAULT_FTP_CONNECT_TIMEOUT));
                } else if (timeouts.length == 3) {
                    fct.setTimeouts(getTimeoutFromString(timeouts[0], DEFAULT_FTP_CONNECT_TIMEOUT),
                            getTimeoutFromString(timeouts[1], DEFAULT_FTP_CONNECT_TIMEOUT),
                            getTimeoutFromString(timeouts[2], DEFAULT_FTP_CONNECT_TIMEOUT));
                }
            } catch (NumberFormatException err) {
                LOG.warn("Incorrect format of ftp connect timeout '" + timeout + "'. " +
                        "Expecting either single value integer either three integers for " +
                        "1. socketTimeout  2. connectTimeout  3. dataTimeout. " +
                        "Default value " + DEFAULT_FTP_CONNECT_TIMEOUT + "ms was used for 2. and 3.");
            }
        }
        String keepAliveTimeout = context.getBuild().getSharedConfigParameters().get(FTPRunnerConstants.PARAM_FTP_CONTROL_KEEP_ALIVE_TIMEOUT);
        if (keepAliveTimeout != null && !keepAliveTimeout.isEmpty()) {
            try {
                fct.setControlKeepAliveTimeout(getTimeoutFromString(keepAliveTimeout, -1));
            } catch (NumberFormatException e) {
                LOG.warn("Incorrect value of controlKeepAliveTimeout '" + keepAliveTimeout + "'. " +
                        "Disabling setting this timeout by default.");
            }
        }
        return fct;
    }