From 121e3540cc4cc6d09b546835ee910ecf03d02dc3 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 23 Nov 2023 16:15:01 +0100 Subject: [PATCH] Clear cached executors in setBeanFactory (for reused AspectJ aspect) Closes gh-28201 --- .../aop/interceptor/AsyncExecutionAspectSupport.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 5d35e87994b..3a37fcb1196 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-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -73,8 +73,6 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { protected final Log logger = LogFactory.getLog(getClass()); - private final Map executors = new ConcurrentHashMap<>(16); - private SingletonSupplier defaultExecutor; private SingletonSupplier exceptionHandler; @@ -85,6 +83,9 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { @Nullable private StringValueResolver embeddedValueResolver; + private final Map executors = new ConcurrentHashMap<>(16); + + /** * Create a new instance with a default {@link AsyncUncaughtExceptionHandler}. * @param defaultExecutor the {@code Executor} (typically a Spring {@code AsyncTaskExecutor} @@ -157,6 +158,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { if (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory) { this.embeddedValueResolver = new EmbeddedValueResolver(configurableBeanFactory); } + this.executors.clear(); }