Switch to using TimeUnit.UNIT.toUnit(...)

This commit is contained in:
Josh Soref committed 2019-02-26 12:13:41 -05:00
1 parent 6811328320
commit 0ad7d00099
15 files changed
+38 -26

No files matched your search

@@ -47,6 +47,7 @@ import java.net.URL;
import java.net.URLConnection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import javax.annotation.CheckForNull;
import jenkins.model.Jenkins;
@@ -85,7 +86,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
* Holds a default TCP connect timeout set on all connections returned from this class,
* note this is value is in milliseconds, it's passed directly to {@link URLConnection#setConnectTimeout(int)}
*/
private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = SystemProperties.getInteger("hudson.ProxyConfiguration.DEFAULT_CONNECT_TIMEOUT_MILLIS", 20 * 1000);
private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = SystemProperties.getInteger("hudson.ProxyConfiguration.DEFAULT_CONNECT_TIMEOUT_MILLIS", (int)TimeUnit.SECONDS.toMillis(20));
public final String name;
public final int port;
@@ -395,7 +396,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
GetMethod method = null;
try {
method = new GetMethod(testUrl);
method.getParams().setParameter("http.socket.timeout", DEFAULT_CONNECT_TIMEOUT_MILLIS > 0 ? DEFAULT_CONNECT_TIMEOUT_MILLIS : 30 * 1000);
method.getParams().setParameter("http.socket.timeout", DEFAULT_CONNECT_TIMEOUT_MILLIS > 0 ? DEFAULT_CONNECT_TIMEOUT_MILLIS : TimeUnit.SECONDS.toMillis(30));
HttpClient client = new HttpClient();
if (Util.fixEmptyAndTrim(name) != null && !isNoProxyHost(host, noProxyHost)) {