ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject [36/50] [abbrv] ant-ivy git commit: Use the specified timeout for connections in BasicURLHandler
Date Thu, 25 May 2017 13:49:22 GMT
Use the specified timeout for connections in BasicURLHandler


Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/c1ad21bf
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/c1ad21bf
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/c1ad21bf

Branch: refs/heads/xooki2asciidoc
Commit: c1ad21bf966d01dc5cceca82f102c0f7843d5617
Parents: 658a8d8
Author: Jaikiran Pai <jaikiran.pai@gmail.com>
Authored: Sun May 21 10:59:58 2017 +0530
Committer: Jaikiran Pai <jaikiran.pai@gmail.com>
Committed: Sun May 21 10:59:58 2017 +0530

----------------------------------------------------------------------
 src/java/org/apache/ivy/util/url/BasicURLHandler.java    |  1 +
 .../org/apache/ivy/util/url/BasicURLHandlerTest.java     | 11 ++++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/c1ad21bf/src/java/org/apache/ivy/util/url/BasicURLHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/url/BasicURLHandler.java b/src/java/org/apache/ivy/util/url/BasicURLHandler.java
index 72641ef..0ad23c5 100644
--- a/src/java/org/apache/ivy/util/url/BasicURLHandler.java
+++ b/src/java/org/apache/ivy/util/url/BasicURLHandler.java
@@ -64,6 +64,7 @@ public class BasicURLHandler extends AbstractURLHandler {
         try {
             url = normalizeToURL(url);
             con = url.openConnection();
+            con.setConnectTimeout(timeout);
             con.setRequestProperty("User-Agent", getUserAgent());
             if (con instanceof HttpURLConnection) {
                 HttpURLConnection httpCon = (HttpURLConnection) con;

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/c1ad21bf/test/java/org/apache/ivy/util/url/BasicURLHandlerTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/util/url/BasicURLHandlerTest.java b/test/java/org/apache/ivy/util/url/BasicURLHandlerTest.java
index 8ce9955..c6da184 100644
--- a/test/java/org/apache/ivy/util/url/BasicURLHandlerTest.java
+++ b/test/java/org/apache/ivy/util/url/BasicURLHandlerTest.java
@@ -45,15 +45,16 @@ public class BasicURLHandlerTest extends TestCase {
     }
 
     public void testIsReachable() throws Exception {
-        assertTrue(handler.isReachable(new URL("http://www.google.fr/")));
-        assertFalse(handler.isReachable(new URL("http://www.google.fr/unknownpage.html")));
+        final int connectionTimeoutInMillis = 15000; // 15 seconds
+        assertTrue(handler.isReachable(new URL("http://www.google.fr/"), connectionTimeoutInMillis));
+        assertFalse(handler.isReachable(new URL("http://www.google.fr/unknownpage.html"),
connectionTimeoutInMillis));
 
-        assertTrue(handler.isReachable(new File("build.xml").toURI().toURL()));
-        assertFalse(handler.isReachable(new File("unknownfile.xml").toURI().toURL()));
+        assertTrue(handler.isReachable(new File("build.xml").toURI().toURL(), connectionTimeoutInMillis));
+        assertFalse(handler.isReachable(new File("unknownfile.xml").toURI().toURL(), connectionTimeoutInMillis));
 
         // to test ftp we should know of an anonymous ftp site... !
         // assertTrue(handler.isReachable(new URL("ftp://ftp.mozilla.org/pub/dir.sizes")));
-        assertFalse(handler.isReachable(new URL("ftp://ftp.mozilla.org/unknown.file")));
+        assertFalse(handler.isReachable(new URL("ftp://ftp.mozilla.org/unknown.file"), connectionTimeoutInMillis));
     }
 
     public void testContentEncoding() throws Exception {


Mime
View raw message