• 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

0.0
today-context/src/main/java/infra/scheduling/support/MethodInvokingRunnable.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.support;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.lang.reflect.InvocationTargetException;
23

24
import infra.beans.factory.BeanClassLoaderAware;
25
import infra.beans.factory.InitializingBean;
26
import infra.beans.support.ArgumentConvertingMethodInvoker;
27
import infra.logging.Logger;
28
import infra.logging.LoggerFactory;
29
import infra.util.ClassUtils;
30
import infra.util.ReflectiveMethodInvoker;
31

32
/**
33
 * Adapter that implements the {@link Runnable} interface as a configurable
34
 * method invocation based on Framework's MethodInvoker.
35
 *
36
 * <p>Inherits common configuration properties from
37
 * {@link ReflectiveMethodInvoker}.
38
 *
39
 * @author Juergen Hoeller
40
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
41
 * @see java.util.concurrent.Executor#execute(Runnable)
42
 * @since 4.0 2022/2/18 11:18
43
 */
44
public class MethodInvokingRunnable extends ArgumentConvertingMethodInvoker
×
45
        implements Runnable, BeanClassLoaderAware, InitializingBean {
46

47
  private static final Logger log = LoggerFactory.getLogger(MethodInvokingRunnable.class);
×
48

49
  @Nullable
×
50
  private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
×
51

52
  @Override
53
  public void setBeanClassLoader(ClassLoader classLoader) {
54
    this.beanClassLoader = classLoader;
×
55
  }
×
56

57
  @Override
58
  protected Class<?> resolveClassName(String className) throws ClassNotFoundException {
59
    return ClassUtils.forName(className, this.beanClassLoader);
×
60
  }
61

62
  @Override
63
  public void afterPropertiesSet() throws ClassNotFoundException, NoSuchMethodException {
64
    prepare();
×
65
  }
×
66

67
  @Override
68
  public void run() {
69
    try {
70
      invoke();
×
71
    }
72
    catch (InvocationTargetException ex) {
×
73
      log.error(getInvocationFailureMessage(), ex.getTargetException());
×
74
      // Do not throw exception, else the main loop of the scheduler might stop!
75
    }
76
    catch (Throwable ex) {
×
77
      log.error(getInvocationFailureMessage(), ex);
×
78
      // Do not throw exception, else the main loop of the scheduler might stop!
79
    }
×
80
  }
×
81

82
  /**
83
   * Build a message for an invocation failure exception.
84
   *
85
   * @return the error message, including the target method name etc
86
   */
87
  protected String getInvocationFailureMessage() {
88
    return "Invocation of method '" + getTargetMethod() +
×
89
            "' on target class [" + getTargetClass() + "] failed";
×
90
  }
91

92
}
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