From portal-commits at lists.jboss.org Wed Mar 7 13:17:00 2007 Content-Type: multipart/mixed; boundary="===============0895713766362021910==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6582 - in trunk/common/src/main/org/jboss/portal: test/common and 1 other directory. Date: Wed, 07 Mar 2007 13:16:51 -0500 Message-ID: --===============0895713766362021910== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2007-03-07 13:16:51 -0500 (Wed, 07 Mar 2007) New Revision: 6582 Modified: trunk/common/src/main/org/jboss/portal/common/util/URLTools.java trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCase.java Log: improve a bit timeout stuff Modified: trunk/common/src/main/org/jboss/portal/common/util/URLTools.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/common/src/main/org/jboss/portal/common/util/URLTools.java 2007-0= 3-07 17:54:30 UTC (rev 6581) +++ trunk/common/src/main/org/jboss/portal/common/util/URLTools.java 2007-0= 3-07 18:16:51 UTC (rev 6582) @@ -60,7 +60,9 @@ = /** * Fetches content from an HTTP server performing a GET operation. If t= he status code is 200 - * then it will return a byte array of the body otherwise returns null. + * then it will return a byte array of the body otherwise returns null.= The timeout values + * must not be negative integers, when it is equals to zero it means th= at it does not setup + * a timeout and use the default values. * * @param url the URL the URL of the resource * @param soTimeoutMillis the socket connection timeout in millis @@ -73,13 +75,27 @@ { throw new IllegalArgumentException(); } + if (soTimeoutMillis < 0) + { + throw new IllegalArgumentException("No negative socket timeout"); + } + if (connTimeoutMillis < 0) + { + throw new IllegalArgumentException("No negative connection timeou= t"); + } if ("http".equals(url.getProtocol()) || "https".equals(url.getProtoc= ol())) { HttpClient client =3D new HttpClient(); = // Yes deprecated but advocated way to do will not for with 2.0.2= which is what today JBoss AS ships - client.setConnectionTimeout(connTimeoutMillis); - client.setTimeout(soTimeoutMillis); + if (connTimeoutMillis > 0) + { + client.setConnectionTimeout(connTimeoutMillis); + } + if (soTimeoutMillis > 0) + { + client.setTimeout(soTimeoutMillis); + } = // HttpMethod method =3D null; Modified: trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCa= se.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCase.jav= a 2007-03-07 17:54:30 UTC (rev 6581) +++ trunk/common/src/main/org/jboss/portal/test/common/URLToolsTestCase.jav= a 2007-03-07 18:16:51 UTC (rev 6582) @@ -24,7 +24,10 @@ = import junit.framework.TestCase; import org.jboss.portal.common.util.URLTools; +import org.apache.log4j.net.SocketServer; = +import java.net.URL; + /** * @author Chris Laprun * @version $Revision$ --===============0895713766362021910==--