diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java b/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java index f64923e4f0..7ab2b53433 100644 --- a/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java +++ b/configadmin/src/main/java/org/apache/felix/cm/impl/UpdateThread.java @@ -146,13 +146,16 @@ synchronized void start() * initiated will not be processed any more. This method does nothing if * the worker thread is not currently active. *
- * If the worker thread does not terminate within 5 seconds it is killed
- * by calling the (deprecated) Thread.stop() method. It may
- * be that the worker thread may be blocked by a deadlock (it should not,
- * though). In this case hope is that Thread.stop() will be
- * able to released that deadlock at the expense of one or more tasks to
- * not be executed any longer.... In any case an ERROR message is logged
- * with the LogService in this situation.
+ * If the worker thread does not terminate within 5 seconds it is
+ * interrupted. It may be that the worker thread is blocked by a deadlock
+ * (it should not, though); interrupting it releases the thread if it is
+ * waiting on an interruptible operation, at the expense of one or more
+ * tasks not being executed any longer. In any case an ERROR message is
+ * logged with the LogService in this situation.
+ *
+ * This used to call Thread.stop(), which has thrown
+ * UnsupportedOperationException since Java 20 and so could
+ * only turn a slow shutdown into a failed one.
*/
synchronized void terminate()
{
@@ -176,9 +179,9 @@ synchronized void terminate()
if ( workerThread.isAlive() )
{
Log.logger.log( LogService.LOG_ERROR,
- "Worker thread {0} did not terminate within 5 seconds; trying to kill", new Object[]
+ "Worker thread {0} did not terminate within 5 seconds; interrupting it", new Object[]
{ workerBaseName } );
- workerThread.stop();
+ workerThread.interrupt();
}
}
}