From e947363a11ded1c84530baf06c79482feb644758 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 15 Sep 2016 08:54:17 +0200 Subject: [PATCH] Timeout exceptions as RuntimeExceptions Issue: SPR-14669 (cherry picked from commit 6dc1898) --- .../messaging/simp/stomp/ConnectionLostException.java | 4 ++-- .../context/request/async/AsyncRequestTimeoutException.java | 3 ++- .../mvc/method/annotation/ResponseEntityExceptionHandler.java | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/ConnectionLostException.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/ConnectionLostException.java index 9414ee541b0..5710da24cb7 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/ConnectionLostException.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/ConnectionLostException.java @@ -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. @@ -23,7 +23,7 @@ package org.springframework.messaging.simp.stomp; * @since 4.2 */ @SuppressWarnings("serial") -public class ConnectionLostException extends Exception { +public class ConnectionLostException extends RuntimeException { public ConnectionLostException(String message) { super(message); diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/AsyncRequestTimeoutException.java b/spring-web/src/main/java/org/springframework/web/context/request/async/AsyncRequestTimeoutException.java index f079caf53b0..2e5d7488e55 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/AsyncRequestTimeoutException.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/AsyncRequestTimeoutException.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.context.request.async; /** @@ -29,6 +30,6 @@ package org.springframework.web.context.request.async; * @since 4.2.8 */ @SuppressWarnings("serial") -public class AsyncRequestTimeoutException extends Exception { +public class AsyncRequestTimeoutException extends RuntimeException { } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java index f36f38718a6..50f10e4bb9a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java @@ -186,7 +186,9 @@ public abstract class ResponseEntityExceptionHandler { (AsyncRequestTimeoutException) ex, headers, status, request); } else { - logger.warn("Unknown exception type: " + ex.getClass().getName()); + if (logger.isWarnEnabled()) { + logger.warn("Unknown exception type: " + ex.getClass().getName()); + } HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; return handleExceptionInternal(ex, null, headers, status, request); }