You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2025/05/27 10:21:49 UTC
(tomcat) branch 9.0.x updated (edb92552e1 -> 245f079db6)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from edb92552e1 Support parsing multiple path parameters in a single URL segment.
new f7129cf0ee Refactor TaskQueue to use RetryableQueue interface
new 245f079db6 Restore imports incorrectly removed during code formatting
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../util/net/openssl/panama/OpenSSLContext.java | 5 +++
.../util/net/openssl/panama/OpenSSLEngine.java | 5 +++
.../util/net/openssl/panama/OpenSSLLibrary.java | 3 ++
.../net/openssl/panama/OpenSSLSessionContext.java | 2 +
.../net/openssl/panama/OpenSSLSessionStats.java | 2 +
.../apache/tomcat/util/threads/RetryableQueue.java | 52 ++++++++++++++++++++++
java/org/apache/tomcat/util/threads/TaskQueue.java | 27 ++---------
.../tomcat/util/threads/ThreadPoolExecutor.java | 4 +-
webapps/docs/changelog.xml | 11 +++++
9 files changed, 85 insertions(+), 26 deletions(-)
create mode 100644 java/org/apache/tomcat/util/threads/RetryableQueue.java
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/02: Refactor TaskQueue to use RetryableQueue interface
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit f7129cf0eeaea499f513a03e34b4546ddec8d33f
Author: PauloMigAlmeida <pa...@gmail.com>
AuthorDate: Mon May 26 21:35:06 2025 +1200
Refactor TaskQueue to use RetryableQueue interface
Additional clean-up by markt
---
.../apache/tomcat/util/threads/RetryableQueue.java | 52 ++++++++++++++++++++++
java/org/apache/tomcat/util/threads/TaskQueue.java | 27 ++---------
.../tomcat/util/threads/ThreadPoolExecutor.java | 4 +-
webapps/docs/changelog.xml | 11 +++++
4 files changed, 68 insertions(+), 26 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..f636b10dfa
--- /dev/null
+++ b/java/org/apache/tomcat/util/threads/RetryableQueue.java
@@ -0,0 +1,52 @@
+/*
+ * 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;
+import java.util.concurrent.TimeUnit;
+
+public interface RetryableQueue<T> extends BlockingQueue<T> {
+
+ /**
+ * Used to add a task to the queue if the task has been rejected by the Executor.
+ *
+ * @param o The task to add to the queue
+ *
+ * @return {@code true} if the task was added to the queue,
+ * otherwise {@code false}
+ */
+ boolean force(T o);
+
+ /**
+ * Used to add a task to the queue if the task has been rejected by the Executor.
+ *
+ * @param o The task to add to the queue
+ * @param timeout The timeout to use when adding the task
+ * @param unit The units in which the timeout is expressed
+ *
+ * @return {@code true} if the task was added to the queue,
+ * otherwise {@code false}
+ *
+ * @throws InterruptedException If the call is interrupted before the
+ * timeout expires
+ *
+ * @deprecated Unused. Will be removed in Tomcat 10.1.x.
+ */
+ @Deprecated
+ boolean force(Runnable o, long timeout, TimeUnit unit) throws InterruptedException;
+}
diff --git a/java/org/apache/tomcat/util/threads/TaskQueue.java b/java/org/apache/tomcat/util/threads/TaskQueue.java
index 755658a7de..67fe06963b 100644
--- a/java/org/apache/tomcat/util/threads/TaskQueue.java
+++ b/java/org/apache/tomcat/util/threads/TaskQueue.java
@@ -30,7 +30,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> {
private static final long serialVersionUID = 1L;
protected static final StringManager sm = StringManager.getManager(TaskQueue.class);
@@ -54,14 +54,7 @@ public class TaskQueue extends LinkedBlockingQueue<Runnable> {
}
- /**
- * Used to add a task to the queue if the task has been rejected by the Executor.
- *
- * @param o The task to add to the queue
- *
- * @return {@code true} if the task was added to the queue,
- * otherwise {@code false}
- */
+ @Override
public boolean force(Runnable o) {
if (parent == null || parent.isShutdown()) {
throw new RejectedExecutionException(sm.getString("taskQueue.notRunning"));
@@ -70,21 +63,7 @@ public class TaskQueue extends LinkedBlockingQueue<Runnable> {
}
- /**
- * Used to add a task to the queue if the task has been rejected by the Executor.
- *
- * @param o The task to add to the queue
- * @param timeout The timeout to use when adding the task
- * @param unit The units in which the timeout is expressed
- *
- * @return {@code true} if the task was added to the queue,
- * otherwise {@code false}
- *
- * @throws InterruptedException If the call is interrupted before the
- * timeout expires
- *
- * @deprecated Unused. Will be removed in Tomcat 10.1.x.
- */
+ @Override
@Deprecated
public boolean force(Runnable o, long timeout, TimeUnit unit) throws InterruptedException {
if (parent == null || parent.isShutdown()) {
diff --git a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
index 9c0a38590b..acfcb611c1 100644
--- a/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
+++ b/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
@@ -1399,12 +1399,12 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
try {
executeInternal(command);
} catch (RejectedExecutionException rx) {
- if (getQueue() instanceof TaskQueue) {
+ if (getQueue() instanceof RetryableQueue) {
// 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.
// If this happens, add them to the queue.
- final TaskQueue queue = (TaskQueue) getQueue();
+ final RetryableQueue<Runnable> queue = (RetryableQueue<Runnable>) getQueue();
try {
if (!queue.force(command, timeout, unit)) {
submittedCount.decrementAndGet();
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 40cdf0f2b5..25ade009f2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -118,6 +118,17 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Coyote">
+ <changelog>
+ <scode>
+ <pr>861</pr>: Refactor <code>TaskQueue</code> to use the new interface
+ <code>RetryableQueue</code> which enables better integration of custom
+ <code>Executor</code>s which provide their own
+ <code>BlockingQueue</code> implementation. Pull request provided by
+ Paulo Almeida. (markt)
+ </scode>
+ </changelog>
+ </subsection>
<subsection name="Jasper">
<changelog>
<fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/02: Restore imports incorrectly removed during code formatting
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 245f079db6d8bce1ae116cce1f22dd27e00c20f3
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue May 27 11:20:09 2025 +0100
Restore imports incorrectly removed during code formatting
---
java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java | 5 +++++
java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java | 5 +++++
java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java | 3 +++
.../apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java | 2 ++
.../apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java | 2 ++
5 files changed, 17 insertions(+)
diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java
index ad58a8ed39..4b60ec676e 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java
@@ -20,6 +20,11 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.lang.foreign.Arena;
+import java.lang.foreign.MemorySegment;
+import java.lang.foreign.ValueLayout;
+import java.lang.ref.Cleaner;
+import java.lang.ref.Cleaner.Cleanable;
import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.SecureRandom;
diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java
index 2a0311c0ad..e746840683 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java
@@ -18,6 +18,11 @@ package org.apache.tomcat.util.net.openssl.panama;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.lang.foreign.Arena;
+import java.lang.foreign.MemorySegment;
+import java.lang.foreign.ValueLayout;
+import java.lang.ref.Cleaner;
+import java.lang.ref.Cleaner.Cleanable;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
index 68825eb5a7..7272db9cf2 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
@@ -17,6 +17,9 @@
package org.apache.tomcat.util.net.openssl.panama;
+import java.lang.foreign.Arena;
+import java.lang.foreign.MemorySegment;
+import java.lang.foreign.ValueLayout;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java
index 1cfe463912..5921287acd 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.net.openssl.panama;
+import java.lang.foreign.Arena;
+import java.lang.foreign.ValueLayout;
import java.util.Enumeration;
import java.util.NoSuchElementException;
diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java
index 70f71d6c7c..31a3912bef 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.net.openssl.panama;
+import java.lang.foreign.MemorySegment;
+
import static org.apache.tomcat.util.openssl.openssl_h.*;
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org