From b0f0d2f28988eeffff9f6f6bd211c77565cc2704 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 15 May 2014 14:39:06 +0200 Subject: [PATCH] Polishing --- .../AsyncExecutionAspectSupport.java | 4 ++-- .../interceptor/AsyncExecutionInterceptor.java | 17 ++++++++++------- .../expression/spel/SpelMessage.java | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java index c0ff6e5596..3d0840d0b7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -81,7 +81,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { * Set the {@link BeanFactory} to be used when looking up executors by qualifier. */ @Override - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { + public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java index 45df368430..2fa911960a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java @@ -72,6 +72,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport private AsyncUncaughtExceptionHandler exceptionHandler; + /** * Create a new {@code AsyncExecutionInterceptor}. * @param defaultExecutor the {@link Executor} (typically a Spring {@link AsyncTaskExecutor} @@ -90,6 +91,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport this(defaultExecutor, new SimpleAsyncUncaughtExceptionHandler()); } + /** * Supply the {@link AsyncUncaughtExceptionHandler} to use to handle exceptions * thrown by invoking asynchronous methods with a {@code void} return type. @@ -98,6 +100,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport this.exceptionHandler = exceptionHandler; } + /** * Intercept the given method invocation, submit the actual calling of the method to * the correct task executor and return immediately to the caller. @@ -150,7 +153,6 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport * for all other cases, the exception will not be transmitted back to the client. * In that later case, the current {@link AsyncUncaughtExceptionHandler} will be * used to manage such exception. - * * @param ex the exception to handle * @param method the method that was invoked * @param params the parameters used to invoke the method @@ -159,13 +161,14 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport if (method.getReturnType().isAssignableFrom(Future.class)) { ReflectionUtils.rethrowException(ex); } - else { // Could not transmit the exception to the caller with default executor + else { + // Could not transmit the exception to the caller with default executor try { - exceptionHandler.handleUncaughtException(ex, method, params); + this.exceptionHandler.handleUncaughtException(ex, method, params); } - catch (Exception e) { - logger.error("exception handler has thrown an unexpected " + - "exception while invoking '" + method.toGenericString() + "'", e); + catch (Throwable ex2) { + logger.error("Exception handler for async method '" + method.toGenericString() + + "' threw unexpected exception itself", ex2); } } } @@ -175,8 +178,8 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport * Subclasses may override to provide support for extracting qualifier information, * e.g. via an annotation on the given method. * @return always {@code null} - * @see #determineAsyncExecutor(Method) * @since 3.1.2 + * @see #determineAsyncExecutor(Method) */ @Override protected String getExecutorQualifier(Method method) { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java b/spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java index 755feb26e4..834f63b55a 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java @@ -147,7 +147,7 @@ public enum SpelMessage { "The value ''{0}'' cannot be parsed as a long"), INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR(Kind.ERROR, 1037, - "First operand to matches operator must be a string. ''{0}'' is not"), + "First operand to matches operator must be a string. ''{0}'' is not"), INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR(Kind.ERROR, 1038, "Second operand to matches operator must be a string. ''{0}'' is not"), @@ -166,7 +166,7 @@ public enum SpelMessage { "Problem parsing right operand"), NOT_EXPECTED_TOKEN(Kind.ERROR, 1043, - "Unexpected token. Expected ''{0}'' but was ''{1}''"), + "Unexpected token. Expected ''{0}'' but was ''{1}''"), OOD(Kind.ERROR, 1044, "Unexpectedly ran out of input"),