Browse Source

Document exception handling limitations in TaskDecorator implementations

Closes gh-25231
5.0.x
Juergen Hoeller 6 years ago
parent
commit
c2457b960f
  1. 11
      spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java
  2. 7
      spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java
  3. 7
      spring-context/src/main/java/org/springframework/scheduling/concurrent/DefaultManagedTaskExecutor.java
  4. 9
      spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.java
  5. 7
      spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java
  6. 11
      spring-core/src/main/java/org/springframework/core/task/TaskDecorator.java
  7. 7
      spring-core/src/main/java/org/springframework/core/task/support/TaskExecutorAdapter.java
  8. 7
      spring-tx/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java

11
spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -57,9 +57,9 @@ import org.springframework.util.concurrent.ListenableFutureTask;
* <p>The CommonJ WorkManager will usually be retrieved from the application * <p>The CommonJ WorkManager will usually be retrieved from the application
* server's JNDI environment, as defined in the server's management console. * server's JNDI environment, as defined in the server's management console.
* *
* <p>Note: On the upcoming EE 7 compliant versions of WebLogic and WebSphere, a * <p>Note: On EE 7/8 compliant versions of WebLogic and WebSphere, a
* {@link org.springframework.scheduling.concurrent.DefaultManagedTaskExecutor} * {@link org.springframework.scheduling.concurrent.DefaultManagedTaskExecutor}
* should be preferred, following JSR-236 support in Java EE 7. * should be preferred, following JSR-236 support in Java EE 7/8.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.0 * @since 2.0
@ -117,6 +117,11 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
* execution callback (which may be a wrapper around the user-supplied task). * execution callback (which may be a wrapper around the user-supplied task).
* <p>The primary use case is to set some execution context around the task's * <p>The primary use case is to set some execution context around the task's
* invocation, or to provide some monitoring/statistics for task execution. * invocation, or to provide some monitoring/statistics for task execution.
* <p><b>NOTE:</b> Exception handling in {@code TaskDecorator} implementations
* is limited to plain {@code Runnable} execution via {@code execute} calls.
* In case of {@code #submit} calls, the exposed {@code Runnable} will be a
* {@code FutureTask} which does not propagate any exceptions; you might
* have to cast it and call {@code Future#get} to evaluate exceptions.
* @since 4.3 * @since 4.3
*/ */
public void setTaskDecorator(TaskDecorator taskDecorator) { public void setTaskDecorator(TaskDecorator taskDecorator) {

7
spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -129,6 +129,11 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
* execution callback (which may be a wrapper around the user-supplied task). * execution callback (which may be a wrapper around the user-supplied task).
* <p>The primary use case is to set some execution context around the task's * <p>The primary use case is to set some execution context around the task's
* invocation, or to provide some monitoring/statistics for task execution. * invocation, or to provide some monitoring/statistics for task execution.
* <p><b>NOTE:</b> Exception handling in {@code TaskDecorator} implementations
* is limited to plain {@code Runnable} execution via {@code execute} calls.
* In case of {@code #submit} calls, the exposed {@code Runnable} will be a
* {@code FutureTask} which does not propagate any exceptions; you might
* have to cast it and call {@code Future#get} to evaluate exceptions.
* @since 4.3 * @since 4.3
*/ */
public final void setTaskDecorator(TaskDecorator taskDecorator) { public final void setTaskDecorator(TaskDecorator taskDecorator) {

7
spring-context/src/main/java/org/springframework/scheduling/concurrent/DefaultManagedTaskExecutor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import org.springframework.lang.Nullable;
/** /**
* JNDI-based variant of {@link ConcurrentTaskExecutor}, performing a default lookup for * JNDI-based variant of {@link ConcurrentTaskExecutor}, performing a default lookup for
* JSR-236's "java:comp/DefaultManagedExecutorService" in a Java EE 7 environment. * JSR-236's "java:comp/DefaultManagedExecutorService" in a Java EE 7/8 environment.
* *
* <p>Note: This class is not strictly JSR-236 based; it can work with any regular * <p>Note: This class is not strictly JSR-236 based; it can work with any regular
* {@link java.util.concurrent.Executor} that can be found in JNDI. * {@link java.util.concurrent.Executor} that can be found in JNDI.
@ -36,10 +36,11 @@ import org.springframework.lang.Nullable;
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.0 * @since 4.0
* @see javax.enterprise.concurrent.ManagedExecutorService
*/ */
public class DefaultManagedTaskExecutor extends ConcurrentTaskExecutor implements InitializingBean { public class DefaultManagedTaskExecutor extends ConcurrentTaskExecutor implements InitializingBean {
private JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate(); private final JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
@Nullable @Nullable
private String jndiName = "java:comp/DefaultManagedExecutorService"; private String jndiName = "java:comp/DefaultManagedExecutorService";

9
spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -205,6 +205,13 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
* execution callback (which may be a wrapper around the user-supplied task). * execution callback (which may be a wrapper around the user-supplied task).
* <p>The primary use case is to set some execution context around the task's * <p>The primary use case is to set some execution context around the task's
* invocation, or to provide some monitoring/statistics for task execution. * invocation, or to provide some monitoring/statistics for task execution.
* <p><b>NOTE:</b> Exception handling in {@code TaskDecorator} implementations
* is limited to plain {@code Runnable} execution via {@code execute} calls.
* In case of {@code #submit} calls, the exposed {@code Runnable} will be a
* {@code FutureTask} which does not propagate any exceptions; you might
* have to cast it and call {@code Future#get} to evaluate exceptions.
* See the {@code ThreadPoolExecutor#afterExecute} javadoc for an example
* of how to access exceptions in such a {@code Future} case.
* @since 4.3 * @since 4.3
*/ */
public void setTaskDecorator(TaskDecorator taskDecorator) { public void setTaskDecorator(TaskDecorator taskDecorator) {

7
spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -126,6 +126,11 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator
* execution callback (which may be a wrapper around the user-supplied task). * execution callback (which may be a wrapper around the user-supplied task).
* <p>The primary use case is to set some execution context around the task's * <p>The primary use case is to set some execution context around the task's
* invocation, or to provide some monitoring/statistics for task execution. * invocation, or to provide some monitoring/statistics for task execution.
* <p><b>NOTE:</b> Exception handling in {@code TaskDecorator} implementations
* is limited to plain {@code Runnable} execution via {@code execute} calls.
* In case of {@code #submit} calls, the exposed {@code Runnable} will be a
* {@code FutureTask} which does not propagate any exceptions; you might
* have to cast it and call {@code Future#get} to evaluate exceptions.
* @since 4.3 * @since 4.3
*/ */
public final void setTaskDecorator(TaskDecorator taskDecorator) { public final void setTaskDecorator(TaskDecorator taskDecorator) {

11
spring-core/src/main/java/org/springframework/core/task/TaskDecorator.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,17 +27,24 @@ package org.springframework.core.task;
* <p>The primary use case is to set some execution context around the task's * <p>The primary use case is to set some execution context around the task's
* invocation, or to provide some monitoring/statistics for task execution. * invocation, or to provide some monitoring/statistics for task execution.
* *
* <p><b>NOTE:</b> Exception handling in {@code TaskDecorator} implementations
* may be limited. Specifically in case of a {@code Future}-based operation,
* the exposed {@code Runnable} will be a wrapper which does not propagate
* any exceptions from its {@code run} method.
*
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.3 * @since 4.3
* @see TaskExecutor#execute(Runnable) * @see TaskExecutor#execute(Runnable)
* @see SimpleAsyncTaskExecutor#setTaskDecorator * @see SimpleAsyncTaskExecutor#setTaskDecorator
* @see org.springframework.core.task.support.TaskExecutorAdapter#setTaskDecorator
*/ */
@FunctionalInterface @FunctionalInterface
public interface TaskDecorator { public interface TaskDecorator {
/** /**
* Decorate the given {@code Runnable}, returning a potentially wrapped * Decorate the given {@code Runnable}, returning a potentially wrapped
* {@code Runnable} for actual execution. * {@code Runnable} for actual execution, internally delegating to the
* original {@link Runnable#run()} implementation.
* @param runnable the original {@code Runnable} * @param runnable the original {@code Runnable}
* @return the decorated {@code Runnable} * @return the decorated {@code Runnable}
*/ */

7
spring-core/src/main/java/org/springframework/core/task/support/TaskExecutorAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -70,6 +70,11 @@ public class TaskExecutorAdapter implements AsyncListenableTaskExecutor {
* execution callback (which may be a wrapper around the user-supplied task). * execution callback (which may be a wrapper around the user-supplied task).
* <p>The primary use case is to set some execution context around the task's * <p>The primary use case is to set some execution context around the task's
* invocation, or to provide some monitoring/statistics for task execution. * invocation, or to provide some monitoring/statistics for task execution.
* <p><b>NOTE:</b> Exception handling in {@code TaskDecorator} implementations
* is limited to plain {@code Runnable} execution via {@code execute} calls.
* In case of {@code #submit} calls, the exposed {@code Runnable} will be a
* {@code FutureTask} which does not propagate any exceptions; you might
* have to cast it and call {@code Future#get} to evaluate exceptions.
* @since 4.3 * @since 4.3
*/ */
public final void setTaskDecorator(TaskDecorator taskDecorator) { public final void setTaskDecorator(TaskDecorator taskDecorator) {

7
spring-tx/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -174,6 +174,11 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
* execution callback (which may be a wrapper around the user-supplied task). * execution callback (which may be a wrapper around the user-supplied task).
* <p>The primary use case is to set some execution context around the task's * <p>The primary use case is to set some execution context around the task's
* invocation, or to provide some monitoring/statistics for task execution. * invocation, or to provide some monitoring/statistics for task execution.
* <p><b>NOTE:</b> Exception handling in {@code TaskDecorator} implementations
* is limited to plain {@code Runnable} execution via {@code execute} calls.
* In case of {@code #submit} calls, the exposed {@code Runnable} will be a
* {@code FutureTask} which does not propagate any exceptions; you might
* have to cast it and call {@code Future#get} to evaluate exceptions.
* @since 4.3 * @since 4.3
*/ */
public void setTaskDecorator(TaskDecorator taskDecorator) { public void setTaskDecorator(TaskDecorator taskDecorator) {

Loading…
Cancel
Save