Skip to content

Commit 0d60f26

Browse files
committed
Defensively call isShutdown method for executor description
Closes gh-34514 (cherry picked from commit 559ea6c)
1 parent a018ae6 commit 0d60f26

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

spring-core/src/main/java/org/springframework/core/task/TaskRejectedException.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,7 +69,13 @@ public TaskRejectedException(Executor executor, Object task, RejectedExecutionEx
6969

7070
private static String executorDescription(Executor executor) {
7171
if (executor instanceof ExecutorService executorService) {
72-
return "ExecutorService in " + (executorService.isShutdown() ? "shutdown" : "active") + " state";
72+
try {
73+
return "ExecutorService in " + (executorService.isShutdown() ? "shutdown" : "active") + " state";
74+
}
75+
catch (Exception ex) {
76+
// UnsupportedOperationException/IllegalStateException from ManagedExecutorService.isShutdown()
77+
// Falling back to toString() below.
78+
}
7379
}
7480
return executor.toString();
7581
}

0 commit comments

Comments
 (0)