Skip to content

Commit

Permalink
Merge branch 'master' into springboot3
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhom1314 committed Dec 26, 2024
2 parents 15eaaef + 855570d commit 9995293
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<a href="https://gitee.com/dromara/dynamic-tp/members"><img src="https://gitee.com/dromara/dynamic-tp/badge/fork.svg"></a>
<a href="https://github.com/dromara/dynamic-tp"><img src="https://img.shields.io/github/stars/dromara/dynamic-tp?style=flat-square&logo=github"></a>
<a href="https://github.com/dromara/dynamic-tp/network/members"><img src="https://img.shields.io/github/forks/dromara/dynamic-tp?style=flat-square&logo=GitHub"></a>
<a href='https://gitcode.com/dromara/dynamic-tp'><img src='https://gitcode.com/dromara/dynamic-tp/star/badge.svg' alt='fork'></a>
<a href="https://github.com/dromara/dynamic-tp/blob/master/LICENSE"><img src="https://img.shields.io/github/license/dromara/dynamic-tp.svg?style=flat-square"></a>
<a target="_blank" href="/resources/img/contact.jpg"><img src='resources/img/wechat.jpg' alt='备注加群'></a>
</p>

<p align="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static void tryPrintError(Runnable r, Throwable t) {
if (r instanceof FutureTask) {
try {
FutureTask<?> future = (FutureTask<?>) r;
if (future.isDone()) {
if (future.isDone() && !future.isCancelled()) {
future.get();
}
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static Field getField(Class<?> targetClass, String fieldName) {
}

public static Method findMethod(Class<?> targetClass, String methodName, Class<?>... parameterTypes) {
Method method = MethodUtils.getMatchingAccessibleMethod(targetClass, methodName, parameterTypes);
Method method = MethodUtils.getMatchingMethod(targetClass, methodName, parameterTypes);
if (Objects.isNull(method)) {
log.warn("Method '{}' with parameters '{}' not found in class '{}'", methodName, parameterTypes, targetClass.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public ScheduledDtpExecutor(int corePoolSize,
corePoolSize = corePoolSize == 0 ? 1 : corePoolSize;
}
delegate = new ScheduledThreadPoolExecutorProxy(new ScheduledThreadPoolExecutor(corePoolSize, threadFactory, handler));
delegate.setTaskWrappers(getTaskWrappers());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.test.context.junit.jupiter.SpringExtension;

import java.time.LocalDateTime;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

@PropertySource(value = "classpath:/dynamic-tp-nacos-demo-dtp-dev.yml", factory = YamlPropertySourceFactory.class)
Expand Down Expand Up @@ -67,4 +68,14 @@ void testSubNotify() {
dtpExecutor14.shutdownNow();
}

@Test
void testScheduleCancel() {
ScheduledDtpExecutor dtpExecutor12 = (ScheduledDtpExecutor) DtpRegistry.getExecutor("dtpExecutor12");
ScheduledFuture<?> scheduledFuture = dtpExecutor12.scheduleWithFixedDelay(() -> {
System.out.println(Thread.currentThread().getName() + "进来了," +
"当前时间是 ");
}, 0, 1000, TimeUnit.MILLISECONDS);
scheduledFuture.cancel(false);
}

}

0 comments on commit 9995293

Please sign in to comment.