feat: 使用 jdk instanceof 新特性

This commit is contained in:
xingyu4j
2025-08-28 15:10:52 +08:00
parent 495ef72a39
commit 224980aa1a
7 changed files with 12 additions and 20 deletions

View File

@@ -23,15 +23,13 @@ public class YudaoAsyncAutoConfiguration {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
// 处理 ThreadPoolTaskExecutor
if (bean instanceof ThreadPoolTaskExecutor) {
ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) bean;
if (bean instanceof ThreadPoolTaskExecutor executor) {
executor.setTaskDecorator(TtlRunnable::get);
return executor;
}
// 处理 SimpleAsyncTaskExecutor
// 参考 https://t.zsxq.com/CBoks 增加
if (bean instanceof SimpleAsyncTaskExecutor) {
SimpleAsyncTaskExecutor executor = (SimpleAsyncTaskExecutor) bean;
if (bean instanceof SimpleAsyncTaskExecutor executor) {
executor.setTaskDecorator(TtlRunnable::get);
return executor;
}