If we get an async exception, report it to all blocked sync requests.

https://issues.apache.org/activemq/browse/AMQ-691


git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@395641 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-04-20 16:58:58 +00:00
parent 2ee58ca235
commit 9cf5f45cf6
1 changed files with 26 additions and 0 deletions

View File

@ -18,8 +18,12 @@ package org.apache.activemq.transport;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.activemq.command.Command;
import org.apache.activemq.command.ExceptionResponse;
import org.apache.activemq.command.Response;
import org.apache.activemq.util.IntSequenceGenerator;
import org.apache.commons.logging.Log;
@ -94,6 +98,28 @@ public class ResponseCorrelator extends TransportFilter {
}
}
/**
* If an async exception occurs, then assume no responses will arrive for any of
* current requests. Lets let them know of the problem.
*/
public void onException(IOException error) {
// Copy and Clear the request Map
ArrayList requests = new ArrayList(requestMap.values());
requestMap.clear();
for (Iterator iter = requests.iterator(); iter.hasNext();) {
try {
FutureResponse fr = (FutureResponse) iter.next();
fr.set(new ExceptionResponse(error));
} catch (InterruptedIOException e) {
Thread.currentThread().interrupt();
}
}
super.onException(error);
}
public IntSequenceGenerator getSequenceGenerator() {
return sequenceGenerator;
}