Skip to content

Commit 7fad14e

Browse files
committed
#246: Provide a more user-friendly message when send async emails when the executor service has already been shut down (which is possible if it was provided by the user)
1 parent 79d2b9e commit 7fad14e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

modules/batch-module/src/main/java/org/simplejavamail/internal/batchsupport/AsyncOperationHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package org.simplejavamail.internal.batchsupport;
22

3+
import org.jetbrains.annotations.NotNull;
34
import org.simplejavamail.api.mailer.AsyncResponse;
45
import org.simplejavamail.internal.batchsupport.concurrent.NamedRunnable;
56
import org.slf4j.Logger;
67

7-
import org.jetbrains.annotations.NotNull;
88
import java.util.concurrent.ExecutorService;
99
import java.util.concurrent.Executors;
1010
import java.util.concurrent.atomic.AtomicReference;
1111

1212
import static java.util.concurrent.Executors.newSingleThreadExecutor;
13+
import static org.simplejavamail.internal.util.Preconditions.assumeTrue;
1314
import static org.slf4j.LoggerFactory.getLogger;
1415

1516
/**
@@ -51,6 +52,7 @@ private static AsyncResponse executeAsync(final @NotNull ExecutorService executo
5152
// atomic reference is needed to be able to smuggle the asyncResponse
5253
// into the Runnable which is passed itself to the asyncResponse.
5354
final AtomicReference<AsyncResponseImpl> asyncResponseRef = new AtomicReference<>();
55+
assumeTrue(!executorService.isShutdown(), "cannot send async email, executor service is already shut down!");
5456
asyncResponseRef.set(new AsyncResponseImpl(executorService.submit(new NamedRunnable(processName) {
5557
@Override
5658
public void run() {

0 commit comments

Comments
 (0)