diff -ur commons-httpclient-3.0.1.orig/src/java/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java commons-httpclient-3.0.1/src/java/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java --- commons-httpclient-3.0.1.orig/src/java/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java 2008-01-24 13:35:59.928875473 -0600 +++ commons-httpclient-3.0.1/src/java/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java 2008-01-24 13:43:34.616876612 -0600 @@ -70,6 +70,7 @@ * @return a connected Socket * * @throws IOException if an I/O error occurs while creating the socket + * @throws IOException if the thread invoking this method is interrupted * @throws UnknownHostException if the IP address of the host cannot be * determined * @throws ConnectTimeoutException if socket cannot be connected within the @@ -96,6 +97,8 @@ throw new ConnectTimeoutException( "The host did not accept the connection within timeout of " + timeout + " ms"); + } catch (InterruptedException e) { + throw (IOException)new IOException("thread interrupted").initCause(e); } Socket socket = task.getSocket(); if (task.exception != null) { @@ -113,6 +116,8 @@ throw new ConnectTimeoutException( "The host did not accept the connection within timeout of " + timeout + " ms"); + } catch (InterruptedException e) { + throw (IOException)new IOException("thread interrupted").initCause(e); } Socket socket = task.getSocket(); if (task.exception != null) { diff -ur commons-httpclient-3.0.1.orig/src/java/org/apache/commons/httpclient/util/TimeoutController.java commons-httpclient-3.0.1/src/java/org/apache/commons/httpclient/util/TimeoutController.java --- commons-httpclient-3.0.1.orig/src/java/org/apache/commons/httpclient/util/TimeoutController.java 2008-01-24 13:35:59.908875629 -0600 +++ commons-httpclient-3.0.1/src/java/org/apache/commons/httpclient/util/TimeoutController.java 2008-01-24 13:42:48.418080402 -0600 @@ -55,14 +55,12 @@ * @param task The thread to execute * @param timeout The timeout in milliseconds. 0 means to wait forever. * @throws TimeoutException if the timeout passes and the thread does not return. + * @throws InterruptedException if thread invoking this method gets interrupted */ - public static void execute(Thread task, long timeout) throws TimeoutException { + public static void execute(Thread task, long timeout) throws TimeoutException, + InterruptedException { task.start(); - try { - task.join(timeout); - } catch (InterruptedException e) { - /* if somebody interrupts us he knows what he is doing */ - } + task.join(timeout); if (task.isAlive()) { task.interrupt(); throw new TimeoutException(); @@ -74,8 +72,10 @@ * @param task The task to execute * @param timeout The timeout in milliseconds. 0 means to wait forever. * @throws TimeoutException if the timeout passes and the thread does not return. + * @throws InterruptedException if thread invoking this method gets interrupted */ - public static void execute(Runnable task, long timeout) throws TimeoutException { + public static void execute(Runnable task, long timeout) throws TimeoutException, + InterruptedException { Thread t = new Thread(task, "Timeout guard"); t.setDaemon(true); execute(t, timeout);