Clear cached executors in setBeanFactory (for reused AspectJ aspect)

Closes gh-28201
This commit is contained in:
Juergen Hoeller 2023-11-23 16:15:01 +01:00
parent 0d8dee2878
commit 121e3540cc
1 changed files with 5 additions and 3 deletions

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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()); protected final Log logger = LogFactory.getLog(getClass());
private final Map<Method, AsyncTaskExecutor> executors = new ConcurrentHashMap<>(16);
private SingletonSupplier<Executor> defaultExecutor; private SingletonSupplier<Executor> defaultExecutor;
private SingletonSupplier<AsyncUncaughtExceptionHandler> exceptionHandler; private SingletonSupplier<AsyncUncaughtExceptionHandler> exceptionHandler;
@ -85,6 +83,9 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
@Nullable @Nullable
private StringValueResolver embeddedValueResolver; private StringValueResolver embeddedValueResolver;
private final Map<Method, AsyncTaskExecutor> executors = new ConcurrentHashMap<>(16);
/** /**
* Create a new instance with a default {@link AsyncUncaughtExceptionHandler}. * Create a new instance with a default {@link AsyncUncaughtExceptionHandler}.
* @param defaultExecutor the {@code Executor} (typically a Spring {@code AsyncTaskExecutor} * @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) { if (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory) {
this.embeddedValueResolver = new EmbeddedValueResolver(configurableBeanFactory); this.embeddedValueResolver = new EmbeddedValueResolver(configurableBeanFactory);
} }
this.executors.clear();
} }