Defensive catching of any Throwable subclasses instead of just Error

Issue: SPR-14329
This commit is contained in:
Juergen Hoeller 2016-06-04 00:17:20 +02:00
parent f657952cee
commit a9fda3e7e2
5 changed files with 11 additions and 11 deletions

View File

@ -126,7 +126,7 @@ public abstract class AbstractMessageChannel implements MessageChannel, Intercep
}
throw new MessageDeliveryException(message,"Failed to send message to " + this, ex);
}
catch (Error err) {
catch (Throwable err) {
MessageDeliveryException ex2 =
new MessageDeliveryException(message, "Failed to send message to " + this, err);
chain.triggerAfterSendCompletion(message, this, sent, ex2);

View File

@ -143,7 +143,7 @@ public class ExecutorSubscribableChannel extends AbstractSubscribableChannel {
String description = "Failed to handle " + message + " to " + this + " in " + this.messageHandler;
throw new MessageDeliveryException(message, description, ex);
}
catch (Error err) {
catch (Throwable err) {
String description = "Failed to handle " + message + " to " + this + " in " + this.messageHandler;
MessageDeliveryException ex2 = new MessageDeliveryException(message, description, err);
triggerAfterMessageHandled(message, ex2);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -142,7 +142,7 @@ public class TransactionTemplate extends DefaultTransactionDefinition
rollbackOnException(status, err);
throw err;
}
catch (Exception ex) {
catch (Throwable ex) {
// Transactional code threw unexpected exception -> rollback
rollbackOnException(status, ex);
throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -687,7 +687,7 @@ public class DispatcherPortlet extends FrameworkPortlet {
throw ex;
}
}
catch (Error err) {
catch (Throwable err) {
PortletException ex =
new PortletException("Error occured during request processing: " + err.getMessage(), err);
// Trigger after-completion for thrown exception.
@ -800,7 +800,7 @@ public class DispatcherPortlet extends FrameworkPortlet {
triggerAfterRenderCompletion(mappedHandler, interceptorIndex, request, response, ex);
throw ex;
}
catch (Error err) {
catch (Throwable err) {
PortletException ex =
new PortletException("Error occured during request processing: " + err.getMessage(), err);
// Trigger after-completion for thrown exception.
@ -891,7 +891,7 @@ public class DispatcherPortlet extends FrameworkPortlet {
triggerAfterResourceCompletion(mappedHandler, interceptorIndex, request, response, ex);
throw ex;
}
catch (Error err) {
catch (Throwable err) {
PortletException ex =
new PortletException("Error occured during request processing: " + err.getMessage(), err);
// Trigger after-completion for thrown exception.
@ -965,7 +965,7 @@ public class DispatcherPortlet extends FrameworkPortlet {
throw ex;
}
}
catch (Error err) {
catch (Throwable err) {
PortletException ex =
new PortletException("Error occured during request processing: " + err.getMessage(), err);
// Trigger after-completion for thrown exception.

View File

@ -972,7 +972,7 @@ public class DispatcherServlet extends FrameworkServlet {
catch (Exception ex) {
dispatchException = ex;
}
catch (Error err) {
catch (Throwable err) {
// As of 4.3, we're processing Errors thrown from handler methods as well,
// making them available for @ExceptionHandler methods and other scenarios.
dispatchException = new NestedServletException("Handler dispatch failed", err);
@ -982,7 +982,7 @@ public class DispatcherServlet extends FrameworkServlet {
catch (Exception ex) {
triggerAfterCompletion(processedRequest, response, mappedHandler, ex);
}
catch (Error err) {
catch (Throwable err) {
triggerAfterCompletion(processedRequest, response, mappedHandler,
new NestedServletException("Handler processing failed", err));
}