added patch to handle timeout exceptions gracefully

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@414823 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-06-16 13:31:53 +00:00
parent 60ba9da302
commit 319033f712
1 changed files with 14 additions and 4 deletions

View File

@ -20,11 +20,14 @@ import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
import org.apache.activemq.command.Response; import org.apache.activemq.command.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue; import edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue;
import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit; import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
public class FutureResponse { public class FutureResponse {
private static final Log log = LogFactory.getLog(FutureResponse.class);
private final ResponseCallback responseCallback; private final ResponseCallback responseCallback;
private final ArrayBlockingQueue responseSlot = new ArrayBlockingQueue(1); private final ArrayBlockingQueue responseSlot = new ArrayBlockingQueue(1);
@ -34,10 +37,17 @@ public class FutureResponse {
} }
public Response getResult() throws IOException { public Response getResult() throws IOException {
try { while (true) {
return (Response) responseSlot.take(); try {
} catch (InterruptedException e) { return (Response) responseSlot.take();
throw new InterruptedIOException("Interrupted."); }
catch (InterruptedException e) {
Thread.currentThread().interrupt();
if (log.isDebugEnabled()) {
log.debug("Operation interupted: " + e, e);
}
// throw new InterruptedIOException("Interrupted.");
}
} }
} }