synchronized(this) {
// Get isUpgrade and WebConnection before calling onError
// Just in case onError will complete the async processing.
final boolean isUpgrade = request.isUpgrade();
final WebConnection wc = request.getWebConnection();
try {
context.fireContainerEvent(
ContainerEvent.BEFORE_READ_LISTENER_ON_ERROR, readListener);
readListener.onError(t);
} finally {
if (isUpgrade && wc != null) {
try {
wc.close();
} catch (Exception ignored) {
}
}
context.fireContainerEvent(
ContainerEvent.AFTER_READ_LISTENER_ON_ERROR, readListener);