• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TAKETODAY / today-infrastructure / 18154768944

01 Oct 2025 07:26AM UTC coverage: 81.882% (-0.005%) from 81.887%
18154768944

push

github

web-flow
Merge pull request #290 from TAKETODAY/dev/jspecify

jspecify

59788 of 78013 branches covered (76.64%)

Branch coverage included in aggregate %.

141239 of 167496 relevant lines covered (84.32%)

3.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
today-context/src/main/java/infra/scheduling/annotation/AnnotationAsyncExecutionInterceptor.java
1
/*
2
 * Copyright 2017 - 2025 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17

18
package infra.scheduling.annotation;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.lang.reflect.Method;
23
import java.util.concurrent.Executor;
24

25
import infra.aop.interceptor.AsyncExecutionInterceptor;
26
import infra.aop.interceptor.AsyncUncaughtExceptionHandler;
27
import infra.core.annotation.AnnotatedElementUtils;
28

29
/**
30
 * Specialization of {@link AsyncExecutionInterceptor} that
31
 * delegates method execution to an {@code Executor} based
32
 * on the {@link Async} annotation. Supports detecting
33
 * qualifier metadata via {@code @Async} at the method or
34
 * declaring class level. See {@link #getExecutorQualifier(Method)} for details.
35
 *
36
 * @author Chris Beams
37
 * @author Stephane Nicoll
38
 * @see Async
39
 * @see AsyncAnnotationAdvisor
40
 * @since 4.0
41
 */
42
public class AnnotationAsyncExecutionInterceptor extends AsyncExecutionInterceptor {
43

44
  /**
45
   * Create a new {@code AnnotationAsyncExecutionInterceptor} with the given executor
46
   * and a simple {@link AsyncUncaughtExceptionHandler}.
47
   *
48
   * @param defaultExecutor the executor to be used by default if no more specific
49
   * executor has been qualified at the method level using {@link Async#value()};
50
   * Now a local executor for this interceptor will be built otherwise
51
   */
52
  public AnnotationAsyncExecutionInterceptor(@Nullable Executor defaultExecutor) {
53
    super(defaultExecutor);
3✔
54
  }
1✔
55

56
  /**
57
   * Create a new {@code AnnotationAsyncExecutionInterceptor} with the given executor.
58
   *
59
   * @param defaultExecutor the executor to be used by default if no more specific
60
   * executor has been qualified at the method level using {@link Async#value()};
61
   * a local executor for this interceptor will be built otherwise
62
   * @param exceptionHandler the {@link AsyncUncaughtExceptionHandler} to use to
63
   * handle exceptions thrown by asynchronous method executions with {@code void}
64
   * return type
65
   */
66
  public AnnotationAsyncExecutionInterceptor(@Nullable Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler) {
67
    super(defaultExecutor, exceptionHandler);
×
68
  }
×
69

70
  /**
71
   * Return the qualifier or bean name of the executor to be used when executing the
72
   * given method, specified via {@link Async#value} at the method or declaring
73
   * class level. If {@code @Async} is specified at both the method and class level, the
74
   * method's {@code #value} takes precedence (even if empty string, indicating that
75
   * the default executor should be used preferentially).
76
   *
77
   * @param method the method to inspect for executor qualifier metadata
78
   * @return the qualifier if specified, otherwise empty string indicating that the
79
   * {@linkplain #setExecutor(Executor) default executor} should be used
80
   * @see #determineAsyncExecutor(Method)
81
   */
82
  @Override
83
  @Nullable
84
  protected String getExecutorQualifier(Method method) {
85
    // Maintainer's note: changes made here should also be made in
86
    // AnnotationAsyncExecutionAspect#getExecutorQualifier
87
    Async async = AnnotatedElementUtils.findMergedAnnotation(method, Async.class);
5✔
88
    if (async == null) {
2✔
89
      async = AnnotatedElementUtils.findMergedAnnotation(method.getDeclaringClass(), Async.class);
6✔
90
    }
91
    return async != null ? async.value() : null;
6!
92
  }
93

94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc