Merge branch '6.2.x'
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Has been cancelled
Details
Deploy Docs / Dispatch docs deployment (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:24], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
Update Antora UI Spring / Update on Supported Branches (6.1.x) (push) Has been cancelled
Details
Update Antora UI Spring / Update on docs-build (push) Has been cancelled
Details
Build and Deploy Snapshot / Verify (push) Has been cancelled
Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Has been cancelled
Details
Deploy Docs / Dispatch docs deployment (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:24], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
Update Antora UI Spring / Update on Supported Branches (6.1.x) (push) Has been cancelled
Details
Update Antora UI Spring / Update on docs-build (push) Has been cancelled
Details
Build and Deploy Snapshot / Verify (push) Has been cancelled
Details
This commit is contained in:
commit
4bfc129f84
|
@ -360,7 +360,7 @@ public class SimpleAsyncTaskScheduler extends SimpleAsyncTaskExecutor implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRunning() {
|
public boolean isRunning() {
|
||||||
return this.triggerLifecycle.isRunning();
|
return (this.triggerLifecycle.isRunning() || this.fixedDelayLifecycle.isRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -342,7 +342,6 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator
|
||||||
this.active = false;
|
this.active = false;
|
||||||
Set<Thread> threads = this.activeThreads;
|
Set<Thread> threads = this.activeThreads;
|
||||||
if (threads != null) {
|
if (threads != null) {
|
||||||
threads.forEach(Thread::interrupt);
|
|
||||||
synchronized (threads) {
|
synchronized (threads) {
|
||||||
try {
|
try {
|
||||||
if (!threads.isEmpty()) {
|
if (!threads.isEmpty()) {
|
||||||
|
@ -353,6 +352,7 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
threads.forEach(Thread::interrupt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||||
|
import org.springframework.transaction.event.TransactionPhase;
|
||||||
|
import org.springframework.transaction.event.TransactionalApplicationListenerMethodAdapter;
|
||||||
import org.springframework.transaction.event.TransactionalEventListenerFactory;
|
import org.springframework.transaction.event.TransactionalEventListenerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,20 +39,22 @@ public class RestrictedTransactionalEventListenerFactory extends TransactionalEv
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationListener<?> createApplicationListener(String beanName, Class<?> type, Method method) {
|
public ApplicationListener<?> createApplicationListener(String beanName, Class<?> type, Method method) {
|
||||||
Transactional txAnn = AnnotatedElementUtils.findMergedAnnotation(method, Transactional.class);
|
TransactionalApplicationListenerMethodAdapter adapter =
|
||||||
|
new TransactionalApplicationListenerMethodAdapter(beanName, type, method);
|
||||||
if (txAnn == null) {
|
if (adapter.getTransactionPhase() != TransactionPhase.BEFORE_COMMIT) {
|
||||||
txAnn = AnnotatedElementUtils.findMergedAnnotation(type, Transactional.class);
|
Transactional txAnn = AnnotatedElementUtils.findMergedAnnotation(method, Transactional.class);
|
||||||
}
|
if (txAnn == null) {
|
||||||
|
txAnn = AnnotatedElementUtils.findMergedAnnotation(type, Transactional.class);
|
||||||
if (txAnn != null) {
|
}
|
||||||
Propagation propagation = txAnn.propagation();
|
if (txAnn != null) {
|
||||||
if (propagation != Propagation.REQUIRES_NEW && propagation != Propagation.NOT_SUPPORTED) {
|
Propagation propagation = txAnn.propagation();
|
||||||
throw new IllegalStateException("@TransactionalEventListener method must not be annotated with " +
|
if (propagation != Propagation.REQUIRES_NEW && propagation != Propagation.NOT_SUPPORTED) {
|
||||||
"@Transactional unless when declared as REQUIRES_NEW or NOT_SUPPORTED: " + method);
|
throw new IllegalStateException("@TransactionalEventListener method must not be annotated with " +
|
||||||
|
"@Transactional unless when declared as REQUIRES_NEW or NOT_SUPPORTED: " + method);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.createApplicationListener(beanName, type, method);
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,13 @@ class TransactionalApplicationListenerMethodAdapterTests {
|
||||||
assertThatNoException().isThrownBy(() -> factory.createApplicationListener("test", SampleEvents.class, m));
|
assertThatNoException().isThrownBy(() -> factory.createApplicationListener("test", SampleEvents.class, m));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void withTransactionalAnnotationBeforeCommit() {
|
||||||
|
RestrictedTransactionalEventListenerFactory factory = new RestrictedTransactionalEventListenerFactory();
|
||||||
|
Method m = ReflectionUtils.findMethod(SampleEvents.class, "withTransactionalAnnotationBeforeCommit", String.class);
|
||||||
|
assertThatNoException().isThrownBy(() -> factory.createApplicationListener("test", SampleEvents.class, m));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void withTransactionalAnnotationOnEnclosingClass() {
|
void withTransactionalAnnotationOnEnclosingClass() {
|
||||||
RestrictedTransactionalEventListenerFactory factory = new RestrictedTransactionalEventListenerFactory();
|
RestrictedTransactionalEventListenerFactory factory = new RestrictedTransactionalEventListenerFactory();
|
||||||
|
@ -277,6 +284,11 @@ class TransactionalApplicationListenerMethodAdapterTests {
|
||||||
public void withAsyncTransactionalAnnotation(String data) {
|
public void withAsyncTransactionalAnnotation(String data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT)
|
||||||
|
@Transactional
|
||||||
|
public void withTransactionalAnnotationBeforeCommit(String data) {
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
static class SampleEventsWithTransactionalAnnotation {
|
static class SampleEventsWithTransactionalAnnotation {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue