Closed nathanchoui closed 2 months ago
背景
1.1.8-beta版本下
问题描述
在使用ScheduledDtpExecutor时,指定了taskWrapperNames: [ "custom" ]。无论执行ScheduledDtpExecutor的哪个方法都不会执行指定的TaskWrapper。 经过Debug发现,调用路径ScheduledDtpExecutor#execute(Runnable command) --> ScheduledDtpExecutor#schedule(Runnable command, long delay, TimeUnit unit) --> ScheduledThreadPoolExecutor#schedule(Runnable command, long delay, TimeUnit unit) 。 虽然在ScheduledThreadPoolExecutorProxy实现了execute ScheduledThreadPoolExecutorProxy
@Override public void execute(Runnable command) { command = getEnhancedTask(command); AwareManager.execute(this, command); super.execute(command); }
但是在ScheduledDtpExecutor中无论是execute还是schedule方法,都调用的是proxy的schedule方法,该proxy中execute方法根本不会被执行。
这个是设计初衷是什么? 我的理解,executorAware这些扩展在定时任务时失去了意义,可以不支持,但是TaskWrapper是可以实现的,也比较容易实现。 以后版本有支持计划吗?
之前delegate = new ScheduledThreadPoolExecutor(corePoolSize, threadFactory, handler),优化为是用代理但是调用方法没修改,属于bug,感谢指出
背景
1.1.8-beta版本下
问题描述
在使用ScheduledDtpExecutor时,指定了taskWrapperNames: [ "custom" ]。无论执行ScheduledDtpExecutor的哪个方法都不会执行指定的TaskWrapper。 经过Debug发现,调用路径ScheduledDtpExecutor#execute(Runnable command) --> ScheduledDtpExecutor#schedule(Runnable command, long delay, TimeUnit unit) --> ScheduledThreadPoolExecutor#schedule(Runnable command, long delay, TimeUnit unit) 。 虽然在ScheduledThreadPoolExecutorProxy实现了execute ScheduledThreadPoolExecutorProxy
@Override public void execute(Runnable command) { command = getEnhancedTask(command); AwareManager.execute(this, command); super.execute(command); }
但是在ScheduledDtpExecutor中无论是execute还是schedule方法,都调用的是proxy的schedule方法,该proxy中execute方法根本不会被执行。 这个是设计初衷是什么? 我的理解,executorAware这些扩展在定时任务时失去了意义,可以不支持,但是TaskWrapper是可以实现的,也比较容易实现。 以后版本有支持计划吗?
之前delegate = new ScheduledThreadPoolExecutor(corePoolSize, threadFactory, handler),优化为是用代理但是调用方法没修改,属于bug,感谢指出
看源码,设计之初就只支持execute方法,schedule相关方法是否也能支持。并且是否可以提供Callable相关包装的扩展接口。
背景
1.1.8-beta版本下
问题描述
在使用ScheduledDtpExecutor时,指定了taskWrapperNames: [ "custom" ]。无论执行ScheduledDtpExecutor的哪个方法都不会执行指定的TaskWrapper。 经过Debug发现,调用路径ScheduledDtpExecutor#execute(Runnable command) --> ScheduledDtpExecutor#schedule(Runnable command, long delay, TimeUnit unit) --> ScheduledThreadPoolExecutor#schedule(Runnable command, long delay, TimeUnit unit) 。 虽然在ScheduledThreadPoolExecutorProxy实现了execute ScheduledThreadPoolExecutorProxy
但是在ScheduledDtpExecutor中无论是execute还是schedule方法,都调用的是proxy的schedule方法,该proxy中execute方法根本不会被执行。
这个是设计初衷是什么? 我的理解,executorAware这些扩展在定时任务时失去了意义,可以不支持,但是TaskWrapper是可以实现的,也比较容易实现。 以后版本有支持计划吗?