This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 9b27e48a81 Refactor TaskQueue to use RetryableQueue interface 9b27e48a81 is described below commit 9b27e48a81e0ab859a22ba6882815d318bf053fe Author: PauloMigAlmeida <paulo.miguel.almeida.rode...@gmail.com> AuthorDate: Mon May 26 21:35:06 2025 +1200 Refactor TaskQueue to use RetryableQueue interface --- .../apache/tomcat/util/threads/RetryableQueue.java | 26 ++++++++++++++++++++++ java/org/apache/tomcat/util/threads/TaskQueue.java | 2 +- .../tomcat/util/threads/ThreadPoolExecutor.java | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/java/org/apache/tomcat/util/threads/RetryableQueue.java b/java/org/apache/tomcat/util/threads/RetryableQueue.java new file mode 100644 index 0000000000..54da92c4d3 --- /dev/null +++ b/java/org/apache/tomcat/util/threads/RetryableQueue.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tomcat.util.threads; + +import java.util.concurrent.BlockingQueue; + +public interface RetryableQueue<T> extends BlockingQueue<T> { + + boolean force(T o); + +} diff --git a/java/org/apache/tomcat/util/threads/TaskQueue.java b/java/org/apache/tomcat/util/threads/TaskQueue.java index fda8d1c244..f88058eadc 100644 --- a/java/org/apache/tomcat/util/threads/TaskQueue.java +++ b/java/org/apache/tomcat/util/threads/TaskQueue.java @@ -31,7 +31,7 @@ import org.apache.tomcat.util.res.StringManager; * there are idle threads and you won't be able to force items onto the queue * itself. */ -public class TaskQueue extends LinkedBlockingQueue<Runnable> { +public class TaskQueue extends LinkedBlockingQueue<Runnable> implements RetryableQueue<Runnable>{ @Serial private static final long serialVersionUID = 1L; diff --git a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java index 2e5be26325..c32769a1e0 100644 --- a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java +++ b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java @@ -1335,7 +1335,7 @@ public class ThreadPoolExecutor extends AbstractExecutorService { try { executeInternal(command); } catch (RejectedExecutionException rx) { - if (getQueue() instanceof TaskQueue queue) { + if (getQueue() instanceof RetryableQueue<Runnable> queue) { // If the Executor is close to maximum pool size, concurrent // calls to execute() may result (due to Tomcat's use of // TaskQueue) in some tasks being rejected rather than queued. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org