[tomcat] branch main updated: Move the virtual thread executor from modules to the main code
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 2fb2029672 Move the virtual thread executor from modules to the main code 2fb2029672 is described below commit 2fb202967203446c401bf0d5bdaa05ccba1a3541 Author: Mark Thomas AuthorDate: Fri May 12 09:51:43 2023 +0100 Move the virtual thread executor from modules to the main code --- .../catalina/core/VirtualThreadExecutor.java | 27 +++--- webapps/docs/changelog.xml | 6 + webapps/docs/config/executor.xml | 20 ++-- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/modules/loom/src/main/java/org/apache/catalina/core/LoomExecutor.java b/java/org/apache/catalina/core/VirtualThreadExecutor.java similarity index 60% rename from modules/loom/src/main/java/org/apache/catalina/core/LoomExecutor.java rename to java/org/apache/catalina/core/VirtualThreadExecutor.java index d4ae23b021..b5ed201b16 100644 --- a/modules/loom/src/main/java/org/apache/catalina/core/LoomExecutor.java +++ b/java/org/apache/catalina/core/VirtualThreadExecutor.java @@ -1,18 +1,18 @@ /* - * 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 + * 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. + * 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.catalina.core; @@ -24,7 +24,7 @@ import org.apache.catalina.util.LifecycleMBeanBase; /** * An executor that uses a new virtual thread for each task. */ -public class LoomExecutor extends LifecycleMBeanBase implements Executor { +public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executor { private String name; private Thread.Builder threadBuilder; @@ -43,6 +43,7 @@ public class LoomExecutor extends LifecycleMBeanBase implements Executor { threadBuilder.start(command); } + @Override protected void startInternal() throws LifecycleException { threadBuilder = Thread.ofVirtual().name(getName() + "-", 0); @@ -65,4 +66,4 @@ public class LoomExecutor extends LifecycleMBeanBase implements Executor { protected String getObjectNameKeyProperties() { return "type=Executor,name=" + getName(); } -} +} \ No newline at end of file diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index f32f27e33e..17824fc5f1 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -129,6 +129,12 @@ current default separator character of * remains unchanged. (markt) + +Add org.apache.catalina.core.VirtualThreadExecutor, a +virtual thread based executor that may be used with one or more +Connectors to process requests received by those Connectors using +virtual threads. (markt) + diff --git a/webapps/docs/config/executor.xml b/webapps/docs/config/executor.xml index 05b1420b8e..9c04ac673a 100644 --- a/webapps/docs/config/executor.xml +++ b/webapps/docs/config/executor.xml @@ -77,8 +77,12 @@ - - The default implementation supports the following attributes: + This implemtenation uses a pool of platform threads to execute the tasks assigned to the Executor. + + The className attribute must be org.apache.catalina.core.StandardThreadExecutor to use + this implementation. + + The standard implementation supports the following attributes: @@ -118,6 +
[tomcat] branch main updated: Remove unnecessary spaces
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 5300e963ed Remove unnecessary spaces 5300e963ed is described below commit 5300e963ed8116762eae7e9e1f92023529382bc0 Author: Mark Thomas AuthorDate: Fri May 12 09:59:36 2023 +0100 Remove unnecessary spaces --- webapps/docs/config/executor.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapps/docs/config/executor.xml b/webapps/docs/config/executor.xml index 9c04ac673a..55ca482d8a 100644 --- a/webapps/docs/config/executor.xml +++ b/webapps/docs/config/executor.xml @@ -129,7 +129,7 @@ The className attribute must be org.apache.catalina.core.VirtualThreadExecutor to use this implementation. - + The virtual thread implementation does not support any additional attributes. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[GitHub] [tomcat] neillee95 opened a new pull request, #616: Fix backport
neillee95 opened a new pull request, #616: URL: https://github.com/apache/tomcat/pull/616 (no comment) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch main updated: Add support for namePrefix to the virtual thread executor
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 70ebbe75ad Add support for namePrefix to the virtual thread executor 70ebbe75ad is described below commit 70ebbe75ad397d4dc9278a78e58dc1b805fee6a3 Author: Mark Thomas AuthorDate: Fri May 12 10:40:10 2023 +0100 Add support for namePrefix to the virtual thread executor --- java/org/apache/catalina/core/VirtualThreadExecutor.java | 11 ++- webapps/docs/config/executor.xml | 9 - 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/core/VirtualThreadExecutor.java b/java/org/apache/catalina/core/VirtualThreadExecutor.java index b5ed201b16..98fa1edee4 100644 --- a/java/org/apache/catalina/core/VirtualThreadExecutor.java +++ b/java/org/apache/catalina/core/VirtualThreadExecutor.java @@ -28,6 +28,7 @@ public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executo private String name; private Thread.Builder threadBuilder; +private String namePrefix; public void setName(String name) { this.name = name; @@ -38,6 +39,14 @@ public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executo return name; } +public String getNamePrefix() { +return namePrefix; +} + +public void setNamePrefix(String namePrefix) { +this.namePrefix = namePrefix; +} + @Override public void execute(Runnable command) { threadBuilder.start(command); @@ -46,7 +55,7 @@ public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executo @Override protected void startInternal() throws LifecycleException { -threadBuilder = Thread.ofVirtual().name(getName() + "-", 0); +threadBuilder = Thread.ofVirtual().name(getNamePrefix(), 0); setState(LifecycleState.STARTING); } diff --git a/webapps/docs/config/executor.xml b/webapps/docs/config/executor.xml index 55ca482d8a..abffc9f5d1 100644 --- a/webapps/docs/config/executor.xml +++ b/webapps/docs/config/executor.xml @@ -130,7 +130,14 @@ The className attribute must be org.apache.catalina.core.VirtualThreadExecutor to use this implementation. - The virtual thread implementation does not support any additional attributes. + The virtual thread implementation supports the follow attributes: + + + + (String) The name prefix for each thread created by the executor. + The thread name for an individual thread will be namePrefix+threadNumber + + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Buildbot success in on tomcat-11.0.x
Build status: Build succeeded! Worker used: bb_worker2_ubuntu URL: https://ci2.apache.org/#builders/112/builds/371 Blamelist: Mark Thomas Build Text: build successful Status Detected: restored build Build Source Stamp: [branch main] 2fb202967203446c401bf0d5bdaa05ccba1a3541 Steps: worker_preparation: 0 git: 0 shell: 0 shell_1: 0 shell_2: 0 shell_3: 0 shell_4: 0 shell_5: 0 compile: 1 shell_6: 0 shell_7: 0 shell_8: 0 shell_9: 0 Rsync docs to nightlies.apache.org: 0 shell_10: 0 Rsync RAT to nightlies.apache.org: 0 compile_1: 1 shell_11: 0 Rsync Logs to nightlies.apache.org: 0 -- ASF Buildbot - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 10.1.x updated: Back-port virtual thread support
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 3949154e2f Back-port virtual thread support 3949154e2f is described below commit 3949154e2fab7e6ac40f67a8a708aeea1476a0f3 Author: Mark Thomas AuthorDate: Fri May 12 09:54:55 2023 +0100 Back-port virtual thread support --- .../apache/catalina/core/LocalStrings.properties | 2 + .../catalina/core/VirtualThreadExecutor.java | 92 ++ .../org/apache/tomcat/util/compat/Jre21Compat.java | 82 +++ java/org/apache/tomcat/util/compat/JreCompat.java | 41 +- .../tomcat/util/compat/LocalStrings.properties | 6 +- webapps/docs/changelog.xml | 7 ++ webapps/docs/config/executor.xml | 28 ++- 7 files changed, 254 insertions(+), 4 deletions(-) diff --git a/java/org/apache/catalina/core/LocalStrings.properties b/java/org/apache/catalina/core/LocalStrings.properties index dd7e15ee2d..07b88b476e 100644 --- a/java/org/apache/catalina/core/LocalStrings.properties +++ b/java/org/apache/catalina/core/LocalStrings.properties @@ -304,3 +304,5 @@ standardWrapper.waiting=Waiting for [{0}] instance(s) to be deallocated for Serv threadLocalLeakPreventionListener.containerEvent.error=Exception processing container event [{0}] threadLocalLeakPreventionListener.lifecycleEvent.error=Exception processing lifecycle event [{0}] + +virtualThreadExecutor.noVirtualThreads=Virtual threads require a minimum Java version of Java 21 \ No newline at end of file diff --git a/java/org/apache/catalina/core/VirtualThreadExecutor.java b/java/org/apache/catalina/core/VirtualThreadExecutor.java new file mode 100644 index 00..dd8739a179 --- /dev/null +++ b/java/org/apache/catalina/core/VirtualThreadExecutor.java @@ -0,0 +1,92 @@ +/* + * 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.catalina.core; + +import org.apache.catalina.Executor; +import org.apache.catalina.LifecycleException; +import org.apache.catalina.LifecycleState; +import org.apache.catalina.util.LifecycleMBeanBase; +import org.apache.tomcat.util.compat.JreCompat; +import org.apache.tomcat.util.res.StringManager; + +/** + * An executor that uses a new virtual thread for each task. + */ +public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executor { + +private static final StringManager sm = StringManager.getManager(VirtualThreadExecutor.class); + +private final JreCompat jreCompat = JreCompat.getInstance(); + +private String name; +private Object threadBuilder; +private String namePrefix; + +public void setName(String name) { +this.name = name; +} + +@Override +public String getName() { +return name; +} + +public String getNamePrefix() { +return namePrefix; +} + +public void setNamePrefix(String namePrefix) { +this.namePrefix = namePrefix; +} + +@Override +public void execute(Runnable command) { +JreCompat.getInstance().threadBuilderStart(threadBuilder, command); +} + + +@Override +protected void initInternal() throws LifecycleException { +super.initInternal(); +if (!JreCompat.isJre21Available()) { +throw new LifecycleException(sm.getString("virtualThreadExecutor.noVirtualThreads")); +} +} + +@Override +protected void startInternal() throws LifecycleException { +threadBuilder = jreCompat.createVirtualThreadBuilder(getNamePrefix()); +setState(LifecycleState.STARTING); +} + +@Override +protected void stopInternal() throws LifecycleException { +threadBuilder = null; +setState(LifecycleState.STOPPING); +} + +@Override +protected String getDomainInternal() { +// No way to navigate to Engine. Needs to have domain set. +return null; +} + +@Override +protected String getObjectNameKeyProperties() { +return "type=Executor,name=" + getName(); +} +} \ No newline at end of
Re: [tomcat] branch 10.1.x updated: Back-port virtual thread support
On 12/05/2023 10:45, ma...@apache.org wrote: This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 3949154e2f Back-port virtual thread support 3949154e2f is described below commit 3949154e2fab7e6ac40f67a8a708aeea1476a0f3 Author: Mark Thomas AuthorDate: Fri May 12 09:54:55 2023 +0100 Back-port virtual thread support Any reason not to back-port this all the way back to 8.5.x ? The required SocketWrapper sync -> lock changes have already been back-ported as they were needed for a WebSocket fix. Mark - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[GitHub] [tomcat] markt-asf commented on pull request #616: Fix backport
markt-asf commented on PR #616: URL: https://github.com/apache/tomcat/pull/616#issuecomment-1545491107 No explanation was provided for this PR. It is tempting to close it with a similar lack of explanation. However... The purpose of the PR is not obvious from the context (the pros/cons of `trySetAccessible()` and `setAccessible(true)` are not clear cut) and the current code is as intended. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[GitHub] [tomcat] markt-asf closed pull request #616: Fix backport
markt-asf closed pull request #616: Fix backport URL: https://github.com/apache/tomcat/pull/616 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch main updated: Update Commons Daemon to 1.3.4
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 3263e8a814 Update Commons Daemon to 1.3.4 3263e8a814 is described below commit 3263e8a814f08ab34f851b63fc383bad8ef38d31 Author: Mark Thomas AuthorDate: Fri May 12 15:05:16 2023 +0100 Update Commons Daemon to 1.3.4 --- build.properties.default | 12 ++-- webapps/docs/changelog.xml | 7 +++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build.properties.default b/build.properties.default index 59cb9266c5..8a11739e02 100644 --- a/build.properties.default +++ b/build.properties.default @@ -170,20 +170,20 @@ nsis.nsdialogs.dll=${nsis.home}/Plugins/${nsis.arch.dir}nsDialogs.dll nsis.loc=${base-sf.loc}/nsis/nsis-${nsis.version}.zip # - Commons Daemon, version 1.2.0 or later - -commons-daemon.version=1.3.3 +commons-daemon.version=1.3.4 -# checksum for commons-daemon-1.3.3-bin.tar.gz +# checksum for commons-daemon-1.3.4-bin.tar.gz commons-daemon.bin.checksum.enabled=true commons-daemon.bin.checksum.algorithm=SHA-512 -commons-daemon.bin.checksum.value=6600f3c182a46005928a77ade2a7f7e32ba29ebdfdc2255275cbd07445c4d278a96de4d8555031fa90eef29c4f50325b3b79eec0e4e09308d152583807189578 +commons-daemon.bin.checksum.value=adc301fe9c7e50c5ed71c6775c8c41c33a369a05c30785ccb81209089603ae66563e958b466c99fc5cd27c12625bb7def68d7d91933aa8739eb645af37f3d03e -# checksums for commons-daemon-1.3.3-native-src.tar.gz, commons-daemon-1.3.3-bin-windows.zip +# checksums for commons-daemon-1.3.4-native-src.tar.gz, commons-daemon-1.3.4-bin-windows.zip commons-daemon.native.src.checksum.enabled=true commons-daemon.native.src.checksum.algorithm=SHA-512 -commons-daemon.native.src.checksum.value=a3d200e5c35c4f2d397164fbaee52f235d954ba8fe342bf136fb2a7da3ca2df472af31c7f68d71b114ab3632ac712f6c7b7a3d3043f8e754c58c402658e1 +commons-daemon.native.src.checksum.value=3c10ca72fc0eb7f755c0b5452bb6d5e8b42d8f363767ffcd9a6f0883026e688ea7dff50ea05e2675a7cdf9f413cb8012ee6b79e16dfc1cd4d83bd775ea10216c commons-daemon.native.win.checksum.enabled=true commons-daemon.native.win.checksum.algorithm=SHA-512 -commons-daemon.native.win.checksum.value=f291b142dadb179fee6845b4d26a52e7961bd39e57680ce2398505efe8c04de00271ed35bc39392c82d1e2d0f60b868cc5a1e80a7b8af8de923554877e0003ba +commons-daemon.native.win.checksum.value=57a59d402dd0a1c99ed5da062b4616d54679e4208abec8b25742f5bf3ec1ee6b5187bc830edeaa218766215371b5519ce0a7186325c929c86b567a3078aa7555 commons-daemon.home=${base.path}/commons-daemon-${commons-daemon.version} commons-daemon.jar=${commons-daemon.home}/commons-daemon-${commons-daemon.version}.jar diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 17824fc5f1..86996037d1 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -137,6 +137,13 @@ + + + +Update to Commons Daemon 1.3.4. (markt) + + + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 10.1.x updated: Update Commons Daemon to 1.3.4
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 0c914147d7 Update Commons Daemon to 1.3.4 0c914147d7 is described below commit 0c914147d7037addffa12166605a0206c6ebe2a3 Author: Mark Thomas AuthorDate: Fri May 12 15:05:16 2023 +0100 Update Commons Daemon to 1.3.4 --- build.properties.default | 12 ++-- webapps/docs/changelog.xml | 7 +++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build.properties.default b/build.properties.default index 8773ee65b8..0e170b2e22 100644 --- a/build.properties.default +++ b/build.properties.default @@ -188,20 +188,20 @@ nsis.nsdialogs.dll=${nsis.home}/Plugins/${nsis.arch.dir}nsDialogs.dll nsis.loc=${base-sf.loc}/nsis/nsis-${nsis.version}.zip # - Commons Daemon, version 1.2.0 or later - -commons-daemon.version=1.3.3 +commons-daemon.version=1.3.4 -# checksum for commons-daemon-1.3.3-bin.tar.gz +# checksum for commons-daemon-1.3.4-bin.tar.gz commons-daemon.bin.checksum.enabled=true commons-daemon.bin.checksum.algorithm=SHA-512 -commons-daemon.bin.checksum.value=6600f3c182a46005928a77ade2a7f7e32ba29ebdfdc2255275cbd07445c4d278a96de4d8555031fa90eef29c4f50325b3b79eec0e4e09308d152583807189578 +commons-daemon.bin.checksum.value=adc301fe9c7e50c5ed71c6775c8c41c33a369a05c30785ccb81209089603ae66563e958b466c99fc5cd27c12625bb7def68d7d91933aa8739eb645af37f3d03e -# checksums for commons-daemon-1.3.3-native-src.tar.gz, commons-daemon-1.3.3-bin-windows.zip +# checksums for commons-daemon-1.3.4-native-src.tar.gz, commons-daemon-1.3.4-bin-windows.zip commons-daemon.native.src.checksum.enabled=true commons-daemon.native.src.checksum.algorithm=SHA-512 -commons-daemon.native.src.checksum.value=a3d200e5c35c4f2d397164fbaee52f235d954ba8fe342bf136fb2a7da3ca2df472af31c7f68d71b114ab3632ac712f6c7b7a3d3043f8e754c58c402658e1 +commons-daemon.native.src.checksum.value=3c10ca72fc0eb7f755c0b5452bb6d5e8b42d8f363767ffcd9a6f0883026e688ea7dff50ea05e2675a7cdf9f413cb8012ee6b79e16dfc1cd4d83bd775ea10216c commons-daemon.native.win.checksum.enabled=true commons-daemon.native.win.checksum.algorithm=SHA-512 -commons-daemon.native.win.checksum.value=f291b142dadb179fee6845b4d26a52e7961bd39e57680ce2398505efe8c04de00271ed35bc39392c82d1e2d0f60b868cc5a1e80a7b8af8de923554877e0003ba +commons-daemon.native.win.checksum.value=57a59d402dd0a1c99ed5da062b4616d54679e4208abec8b25742f5bf3ec1ee6b5187bc830edeaa218766215371b5519ce0a7186325c929c86b567a3078aa7555 commons-daemon.home=${base.path}/commons-daemon-${commons-daemon.version} commons-daemon.jar=${commons-daemon.home}/commons-daemon-${commons-daemon.version}.jar diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index caf1baf2e9..75c0ae975d 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -130,6 +130,13 @@ + + + +Update to Commons Daemon 1.3.4. (markt) + + + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 9.0.x updated: Update Commons Daemon to 1.3.4
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 The following commit(s) were added to refs/heads/9.0.x by this push: new f170e2391b Update Commons Daemon to 1.3.4 f170e2391b is described below commit f170e2391b051e915498dd887c732f2e91e7bf22 Author: Mark Thomas AuthorDate: Fri May 12 15:05:16 2023 +0100 Update Commons Daemon to 1.3.4 --- build.properties.default | 12 ++-- webapps/docs/changelog.xml | 7 +++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build.properties.default b/build.properties.default index 307c338400..765ad173d9 100644 --- a/build.properties.default +++ b/build.properties.default @@ -193,20 +193,20 @@ nsis.nsdialogs.dll=${nsis.home}/Plugins/${nsis.arch.dir}nsDialogs.dll nsis.loc=${base-sf.loc}/nsis/nsis-${nsis.version}.zip # - Commons Daemon, version 1.2.0 or later - -commons-daemon.version=1.3.3 +commons-daemon.version=1.3.4 -# checksum for commons-daemon-1.3.3-bin.tar.gz +# checksum for commons-daemon-1.3.4-bin.tar.gz commons-daemon.bin.checksum.enabled=true commons-daemon.bin.checksum.algorithm=SHA-512 -commons-daemon.bin.checksum.value=6600f3c182a46005928a77ade2a7f7e32ba29ebdfdc2255275cbd07445c4d278a96de4d8555031fa90eef29c4f50325b3b79eec0e4e09308d152583807189578 +commons-daemon.bin.checksum.value=adc301fe9c7e50c5ed71c6775c8c41c33a369a05c30785ccb81209089603ae66563e958b466c99fc5cd27c12625bb7def68d7d91933aa8739eb645af37f3d03e -# checksums for commons-daemon-1.3.3-native-src.tar.gz, commons-daemon-1.3.3-bin-windows.zip +# checksums for commons-daemon-1.3.4-native-src.tar.gz, commons-daemon-1.3.4-bin-windows.zip commons-daemon.native.src.checksum.enabled=true commons-daemon.native.src.checksum.algorithm=SHA-512 -commons-daemon.native.src.checksum.value=a3d200e5c35c4f2d397164fbaee52f235d954ba8fe342bf136fb2a7da3ca2df472af31c7f68d71b114ab3632ac712f6c7b7a3d3043f8e754c58c402658e1 +commons-daemon.native.src.checksum.value=3c10ca72fc0eb7f755c0b5452bb6d5e8b42d8f363767ffcd9a6f0883026e688ea7dff50ea05e2675a7cdf9f413cb8012ee6b79e16dfc1cd4d83bd775ea10216c commons-daemon.native.win.checksum.enabled=true commons-daemon.native.win.checksum.algorithm=SHA-512 -commons-daemon.native.win.checksum.value=f291b142dadb179fee6845b4d26a52e7961bd39e57680ce2398505efe8c04de00271ed35bc39392c82d1e2d0f60b868cc5a1e80a7b8af8de923554877e0003ba +commons-daemon.native.win.checksum.value=57a59d402dd0a1c99ed5da062b4616d54679e4208abec8b25742f5bf3ec1ee6b5187bc830edeaa218766215371b5519ce0a7186325c929c86b567a3078aa7555 commons-daemon.home=${base.path}/commons-daemon-${commons-daemon.version} commons-daemon.jar=${commons-daemon.home}/commons-daemon-${commons-daemon.version}.jar diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 0514133e5e..9413908290 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -127,6 +127,13 @@ + + + +Update to Commons Daemon 1.3.4. (markt) + + + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Update Commons Daemon to 1.3.4
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new db6b0e4b63 Update Commons Daemon to 1.3.4 db6b0e4b63 is described below commit db6b0e4b63c4c58a367510d0c4bf472dcbd413cd Author: Mark Thomas AuthorDate: Fri May 12 15:05:16 2023 +0100 Update Commons Daemon to 1.3.4 --- build.properties.default | 12 ++-- webapps/docs/changelog.xml | 7 +++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build.properties.default b/build.properties.default index 3fbcbdb3f2..8874848e4f 100644 --- a/build.properties.default +++ b/build.properties.default @@ -197,20 +197,20 @@ nsis.nsdialogs.dll=${nsis.home}/Plugins/${nsis.arch.dir}nsDialogs.dll nsis.loc=${base-sf.loc}/nsis/nsis-${nsis.version}.zip # - Commons Daemon, version 1.2.0 or later - -commons-daemon.version=1.3.3 +commons-daemon.version=1.3.4 -# checksum for commons-daemon-1.3.3-bin.tar.gz +# checksum for commons-daemon-1.3.4-bin.tar.gz commons-daemon.bin.checksum.enabled=true commons-daemon.bin.checksum.algorithm=SHA-512 -commons-daemon.bin.checksum.value=6600f3c182a46005928a77ade2a7f7e32ba29ebdfdc2255275cbd07445c4d278a96de4d8555031fa90eef29c4f50325b3b79eec0e4e09308d152583807189578 +commons-daemon.bin.checksum.value=adc301fe9c7e50c5ed71c6775c8c41c33a369a05c30785ccb81209089603ae66563e958b466c99fc5cd27c12625bb7def68d7d91933aa8739eb645af37f3d03e -# checksums for commons-daemon-1.3.3-native-src.tar.gz, commons-daemon-1.3.3-bin-windows.zip +# checksums for commons-daemon-1.3.4-native-src.tar.gz, commons-daemon-1.3.4-bin-windows.zip commons-daemon.native.src.checksum.enabled=true commons-daemon.native.src.checksum.algorithm=SHA-512 -commons-daemon.native.src.checksum.value=a3d200e5c35c4f2d397164fbaee52f235d954ba8fe342bf136fb2a7da3ca2df472af31c7f68d71b114ab3632ac712f6c7b7a3d3043f8e754c58c402658e1 +commons-daemon.native.src.checksum.value=3c10ca72fc0eb7f755c0b5452bb6d5e8b42d8f363767ffcd9a6f0883026e688ea7dff50ea05e2675a7cdf9f413cb8012ee6b79e16dfc1cd4d83bd775ea10216c commons-daemon.native.win.checksum.enabled=true commons-daemon.native.win.checksum.algorithm=SHA-512 -commons-daemon.native.win.checksum.value=f291b142dadb179fee6845b4d26a52e7961bd39e57680ce2398505efe8c04de00271ed35bc39392c82d1e2d0f60b868cc5a1e80a7b8af8de923554877e0003ba +commons-daemon.native.win.checksum.value=57a59d402dd0a1c99ed5da062b4616d54679e4208abec8b25742f5bf3ec1ee6b5187bc830edeaa218766215371b5519ce0a7186325c929c86b567a3078aa7555 commons-daemon.home=${base.path}/commons-daemon-${commons-daemon.version} commons-daemon.jar=${commons-daemon.home}/commons-daemon-${commons-daemon.version}.jar diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 987f48cdcf..a04e745926 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -114,6 +114,13 @@ + + + +Update to Commons Daemon 1.3.4. (markt) + + + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch main updated: Checkstyle
This is an automated email from the ASF dual-hosted git repository. remm 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 ec50c7333b Checkstyle ec50c7333b is described below commit ec50c7333bd03bd1d43b0bf4d4592b7f51f1c899 Author: remm AuthorDate: Fri May 12 17:05:43 2023 +0200 Checkstyle --- .../org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java | 7 +++ .../org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java | 3 +-- .../tomcat/util/net/openssl/panama/OpenSSLLifecycleListener.java | 7 +++ .../tomcat/util/net/openssl/panama/OpenSSLSessionContext.java | 1 - .../apache/tomcat/util/net/openssl/panama/OpenSSLSessionStats.java | 4 ++-- .../tomcat/util/net/openssl/panama/OpenSSLX509Certificate.java | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java index 92d4ec0772..61d953a1c4 100644 --- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java +++ b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java @@ -16,9 +16,6 @@ */ package org.apache.tomcat.util.net.openssl.panama; -import static org.apache.tomcat.util.openssl.openssl_h.*; -import static org.apache.tomcat.util.openssl.openssl_compat_h.*; - import java.io.File; import java.lang.foreign.Arena; import java.lang.foreign.FunctionDescriptor; @@ -54,6 +51,8 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.X509KeyManager; import javax.net.ssl.X509TrustManager; +import static org.apache.tomcat.util.openssl.openssl_compat_h.*; +import static org.apache.tomcat.util.openssl.openssl_h.*; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.net.AbstractEndpoint; @@ -648,7 +647,7 @@ public class OpenSSLContext implements org.apache.tomcat.util.net.SSLContext { ? localArena.allocateUtf8String(SSLHostConfig.adjustRelativePath(sslHostConfig.getCaCertificateFile())) : null; MemorySegment caCertificatePathNative = sslHostConfig.getCaCertificatePath() != null ? localArena.allocateUtf8String(SSLHostConfig.adjustRelativePath(sslHostConfig.getCaCertificatePath())) : null; -if ((sslHostConfig.getCaCertificateFile() != null || sslHostConfig.getCaCertificatePath() != null) +if ((sslHostConfig.getCaCertificateFile() != null || sslHostConfig.getCaCertificatePath() != null) && SSL_CTX_load_verify_locations(state.sslCtx, caCertificateFileNative == null ? MemorySegment.NULL : caCertificateFileNative, caCertificatePathNative == null ? MemorySegment.NULL : caCertificatePathNative) <= 0) { diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java index 1645f8f0b4..b7e6c15578 100644 --- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java +++ b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java @@ -57,9 +57,8 @@ import javax.net.ssl.SSLSessionBindingEvent; import javax.net.ssl.SSLSessionBindingListener; import javax.net.ssl.SSLSessionContext; -import static org.apache.tomcat.util.openssl.openssl_h.*; import static org.apache.tomcat.util.openssl.openssl_compat_h.*; - +import static org.apache.tomcat.util.openssl.openssl_h.*; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.buf.Asn1Parser; diff --git a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLifecycleListener.java b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLifecycleListener.java index 65b9f7394b..3c2dbdda94 100644 --- a/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLifecycleListener.java +++ b/modules/openssl-foreign/src/main/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLifecycleListener.java @@ -17,15 +17,14 @@ package org.apache.tomcat.util.net.openssl.panama; -import static org.apache.tomcat.util.openssl.openssl_compat_h.FIPS_mode; -import static org.apache.tomcat.util.openssl.openssl_compat_h.FIPS_mode_set; -import static org.apache.tomcat.util.openssl.openssl_h.*; - import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; import java.lang.foreign.ValueLayout; import java.security
[tomcat] branch main updated: Add useVirtualThreads attribute to endpoints.
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 c382352b35 Add useVirtualThreads attribute to endpoints. c382352b35 is described below commit c382352b353bcabad86a646ad02d87108a46e807 Author: Mark Thomas AuthorDate: Fri May 12 17:30:27 2023 +0100 Add useVirtualThreads attribute to endpoints. Refactor VirtualThreadExecutor so it can be used by the Endpoint --- .../apache/catalina/core/LocalStrings.properties | 2 ++ ...tor.java => StandardVirtualThreadExecutor.java} | 18 --- .../apache/tomcat/util/net/AbstractEndpoint.java | 23 +++--- .../tomcat/util/threads/VirtualThreadExecutor.java | 36 ++ webapps/docs/changelog.xml | 4 +-- webapps/docs/config/ajp.xml| 7 + webapps/docs/config/executor.xml | 4 +-- webapps/docs/config/http.xml | 7 + 8 files changed, 88 insertions(+), 13 deletions(-) diff --git a/java/org/apache/catalina/core/LocalStrings.properties b/java/org/apache/catalina/core/LocalStrings.properties index 13cf4491ec..cbc7e4999b 100644 --- a/java/org/apache/catalina/core/LocalStrings.properties +++ b/java/org/apache/catalina/core/LocalStrings.properties @@ -280,6 +280,8 @@ standardService.stop.name=Stopping service [{0}] standardThreadExecutor.notStarted=The executor has not been started +standardVirtualThreadExecutor.notStarted=The executor has not been started + standardWrapper.allocate=Error allocating a servlet instance standardWrapper.allocateException=Allocate exception for servlet [{0}] standardWrapper.deallocateException=Deallocate exception for servlet [{0}] diff --git a/java/org/apache/catalina/core/VirtualThreadExecutor.java b/java/org/apache/catalina/core/StandardVirtualThreadExecutor.java similarity index 75% rename from java/org/apache/catalina/core/VirtualThreadExecutor.java rename to java/org/apache/catalina/core/StandardVirtualThreadExecutor.java index 98fa1edee4..7398655494 100644 --- a/java/org/apache/catalina/core/VirtualThreadExecutor.java +++ b/java/org/apache/catalina/core/StandardVirtualThreadExecutor.java @@ -20,14 +20,18 @@ import org.apache.catalina.Executor; import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleState; import org.apache.catalina.util.LifecycleMBeanBase; +import org.apache.tomcat.util.res.StringManager; +import org.apache.tomcat.util.threads.VirtualThreadExecutor; /** * An executor that uses a new virtual thread for each task. */ -public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executor { +public class StandardVirtualThreadExecutor extends LifecycleMBeanBase implements Executor { + +private static final StringManager sm = StringManager.getManager(StandardVirtualThreadExecutor.class); private String name; -private Thread.Builder threadBuilder; +private java.util.concurrent.Executor executor; private String namePrefix; public void setName(String name) { @@ -49,19 +53,23 @@ public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executo @Override public void execute(Runnable command) { -threadBuilder.start(command); +if (executor == null) { +throw new IllegalStateException(sm.getString("standardVirtualThreadExecutor.notStarted")); +} else { +executor.execute(command); +} } @Override protected void startInternal() throws LifecycleException { -threadBuilder = Thread.ofVirtual().name(getNamePrefix(), 0); +executor = new VirtualThreadExecutor(getNamePrefix()); setState(LifecycleState.STARTING); } @Override protected void stopInternal() throws LifecycleException { -threadBuilder = null; +executor = null; setState(LifecycleState.STOPPING); } diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java b/java/org/apache/tomcat/util/net/AbstractEndpoint.java index d33b33a17f..8698dedf92 100644 --- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java +++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java @@ -61,6 +61,7 @@ import org.apache.tomcat.util.threads.ResizableExecutor; import org.apache.tomcat.util.threads.TaskQueue; import org.apache.tomcat.util.threads.TaskThreadFactory; import org.apache.tomcat.util.threads.ThreadPoolExecutor; +import org.apache.tomcat.util.threads.VirtualThreadExecutor; /** * @param The type used by the socket wrapper associated with this endpoint. @@ -743,6 +744,15 @@ public abstract class AbstractEndpoint { public Executor getExecutor() { return executor; } +private boolean useVirtualThreads = false; +public void setUseVirtualThreads(boolean useVirtualThreads) {
Re: [VOTE] Release Apache Tomcat 8.5.89
All, On 5/9/23 13:38, Christopher Schultz wrote: The proposed Apache Tomcat 8.5.89 release is now available for voting. The notable changes compared to 8.5.88 are: - Many improvements to the JSON access log valve. - Deprecate support for the HTTP Connector settings rejectIllegalHeader and allowHostHeaderMismatch and reject HTTP headers without names. - Add a RateLimitFilter which can be used to mitigate DoS and Brute Force attacks. Along with lots of other bug fixes and improvements. For full details, see the changelog: https://nightlies.apache.org/tomcat/tomcat-8.5.x/docs/changelog.html It can be obtained from: https://dist.apache.org/repos/dist/dev/tomcat/tomcat-8/v8.5.89/ The Maven staging repo is: https://repository.apache.org/content/repositories/orgapachetomcat-1436 The tag is: https://github.com/apache/tomcat/tree/8.5.89/ da91bd19ef2cb34a96e4ad04749dfc97c941db87 The proposed 8.5.89 release is: [ ] Broken - do not release [ ] Stable - go ahead and release as 8.5.88 (stable) I'm getting a unit test failure I don't understand: Testsuite: org.apache.tomcat.websocket.TestWsWebSocketContainerSSL Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.717 sec - Standard Error - 10-May-2023 22:15:22.794 INFO [main] org.apache.catalina.startup.LoggingBaseTest.setUp Starting test case [testConnectToServerEndpointSSL] 10-May-2023 22:15:22.903 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.36] using APR version [1.7.0]. 10-May-2023 22:15:22.904 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [{4}]. 10-May-2023 22:15:22.904 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] 10-May-2023 22:15:22.906 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1 11 Sep 2018] 10-May-2023 22:15:23.117 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-openssl-apr-127.0.0.1-auto-1"] 10-May-2023 22:15:23.192 INFO [main] org.apache.tomcat.util.net.AbstractEndpoint.logCertificate Connector [https-openssl-apr-127.0.0.1-auto-1], TLS virtual host [_default_], certificate type [UNDEFINED] configured from [/home/cschultz/.keystore] using alias [tomcat] and with trust store [/mnt/ephemeral0/cschultz/projects/apache/apache-tomcat/tarball/apache-tomcat-8.5.89-src/test/org/apache/tomcat/util/net/ca-cert.pem] 10-May-2023 22:15:23.203 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Tomcat] 10-May-2023 22:15:23.203 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/8.5.89] 10-May-2023 22:15:23.308 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["https-openssl-apr-127.0.0.1-auto-1-37597"] 10-May-2023 22:15:23.353 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["https-openssl-apr-127.0.0.1-auto-1-37597"] 10-May-2023 22:15:23.361 INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Tomcat] 10-May-2023 22:15:23.368 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["https-openssl-apr-127.0.0.1-auto-1-37597"] 10-May-2023 22:15:23.386 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["https-openssl-apr-127.0.0.1-auto-1-37597"] - --- Testcase: testConnectToServerEndpointSSL took 0.691 sec Caused an ERROR The HTTP request to initiate the WebSocket connection to [wss://localhost:37597/echoAsync] failed javax.websocket.DeploymentException: The HTTP request to initiate the WebSocket connection to [wss://localhost:37597/echoAsync] failed at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:428) at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:170) at org.apache.tomcat.websocket.TestWsWebSocketContainerSSL.testConnectToServerEndpointSSL(TestWsWebSocketContainerSSL.java:64) Caused by: java.util.concurrent.ExecutionException: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WrapperFuture.get(AsyncChannelWrapperSecure.java:489) at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:320) Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) at sun.security.ssl.HandshakeContext.(HandshakeContext.java:171)
Re: [VOTE] Release Apache Tomcat 10.1.9
All, On 5/9/23 12:12, Christopher Schultz wrote: The proposed Apache Tomcat 10.1.9 release is now available for voting. The notable changes compared to 10.1.8 are: - Many improvements to the JSON access log valve. - Deprecate support for the HTTP Connector settings rejectIllegalHeader and allowHostHeaderMismatch and reject HTTP headers without names. - Add a RateLimitFilter which can be used to mitigate DoS and Brute Force attacks. For full details, see the change log: https://nightlies.apache.org/tomcat/tomcat-10.1.x/docs/changelog.html Applications that run on Tomcat 9 and earlier will not run on Tomcat 10 without changes. Java EE applications designed for Tomcat 9 and earlier may be placed in the $CATALINA_BASE/webapps-javaee directory and Tomcat will automatically convert them to Jakarta EE and copy them to the webapps directory. It can be obtained from: https://dist.apache.org/repos/dist/dev/tomcat/tomcat-10/v10.1.9/ The Maven staging repo is: https://repository.apache.org/content/repositories/orgapachetomcat-1435 The tag is: https://github.com/apache/tomcat/tree/10.1.9 5d45c1a9359c2298d7140c1ca90cb8c43809a168 The proposed 10.1.9 release is: [ ] Broken - do not release [ ] Stable - go ahead and release as 10.1.9 Running checkstyle gives me an error something like "cannot create Module Root". I don't have the exact error message, since I just disabled checkstyle and re-ran the build. Anyone ever seen that before? In other checkstyle news, the version of checkstyle used for 8.5.x is too recent for Java 1.8 to run. I think I reported that in the past and the consensus was that "RMs should be using Java 11 or later so that's fine." I'm reporting that just in case I didn't do so before. -chris - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 10.1.x updated: Add useVirtualThreads attribute to endpoints.
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 4416934d4b Add useVirtualThreads attribute to endpoints. 4416934d4b is described below commit 4416934d4b34b27ecb0761c460f12c8b26573db5 Author: Mark Thomas AuthorDate: Fri May 12 17:30:27 2023 +0100 Add useVirtualThreads attribute to endpoints. Refactor VirtualThreadExecutor so it can be used by the Endpoint --- .../apache/catalina/core/LocalStrings.properties | 5 +-- ...tor.java => StandardVirtualThreadExecutor.java} | 21 +++- .../apache/tomcat/util/net/AbstractEndpoint.java | 23 ++--- .../tomcat/util/threads/VirtualThreadExecutor.java | 40 ++ webapps/docs/changelog.xml | 4 +-- webapps/docs/config/ajp.xml| 7 webapps/docs/config/executor.xml | 4 +-- webapps/docs/config/http.xml | 7 8 files changed, 92 insertions(+), 19 deletions(-) diff --git a/java/org/apache/catalina/core/LocalStrings.properties b/java/org/apache/catalina/core/LocalStrings.properties index 07b88b476e..afc4812915 100644 --- a/java/org/apache/catalina/core/LocalStrings.properties +++ b/java/org/apache/catalina/core/LocalStrings.properties @@ -281,6 +281,9 @@ standardService.stop.name=Stopping service [{0}] standardThreadExecutor.notStarted=The executor has not been started +standardVirtualThreadExecutor.notStarted=The executor has not been started +standardVirtualThreadExecutor.noVirtualThreads=Virtual threads require a minimum Java version of Java 21 + standardWrapper.allocate=Error allocating a servlet instance standardWrapper.allocateException=Allocate exception for servlet [{0}] standardWrapper.deallocateException=Deallocate exception for servlet [{0}] @@ -304,5 +307,3 @@ standardWrapper.waiting=Waiting for [{0}] instance(s) to be deallocated for Serv threadLocalLeakPreventionListener.containerEvent.error=Exception processing container event [{0}] threadLocalLeakPreventionListener.lifecycleEvent.error=Exception processing lifecycle event [{0}] - -virtualThreadExecutor.noVirtualThreads=Virtual threads require a minimum Java version of Java 21 \ No newline at end of file diff --git a/java/org/apache/catalina/core/VirtualThreadExecutor.java b/java/org/apache/catalina/core/StandardVirtualThreadExecutor.java similarity index 78% rename from java/org/apache/catalina/core/VirtualThreadExecutor.java rename to java/org/apache/catalina/core/StandardVirtualThreadExecutor.java index dd8739a179..23663c4e4e 100644 --- a/java/org/apache/catalina/core/VirtualThreadExecutor.java +++ b/java/org/apache/catalina/core/StandardVirtualThreadExecutor.java @@ -22,18 +22,17 @@ import org.apache.catalina.LifecycleState; import org.apache.catalina.util.LifecycleMBeanBase; import org.apache.tomcat.util.compat.JreCompat; import org.apache.tomcat.util.res.StringManager; +import org.apache.tomcat.util.threads.VirtualThreadExecutor; /** * An executor that uses a new virtual thread for each task. */ -public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executor { +public class StandardVirtualThreadExecutor extends LifecycleMBeanBase implements Executor { -private static final StringManager sm = StringManager.getManager(VirtualThreadExecutor.class); - -private final JreCompat jreCompat = JreCompat.getInstance(); +private static final StringManager sm = StringManager.getManager(StandardVirtualThreadExecutor.class); private String name; -private Object threadBuilder; +private java.util.concurrent.Executor executor; private String namePrefix; public void setName(String name) { @@ -55,7 +54,11 @@ public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executo @Override public void execute(Runnable command) { -JreCompat.getInstance().threadBuilderStart(threadBuilder, command); +if (executor == null) { +throw new IllegalStateException(sm.getString("standardVirtualThreadExecutor.notStarted")); +} else { +executor.execute(command); +} } @@ -63,19 +66,19 @@ public class VirtualThreadExecutor extends LifecycleMBeanBase implements Executo protected void initInternal() throws LifecycleException { super.initInternal(); if (!JreCompat.isJre21Available()) { -throw new LifecycleException(sm.getString("virtualThreadExecutor.noVirtualThreads")); +throw new LifecycleException(sm.getString("standardVirtualThreadExecutor.noVirtualThreads")); } } @Override protected void startInternal() throws LifecycleException { -threadBuilder = jreCompat.createVirtualThreadBuilder(getNamePrefix()); +executor = new Virt
Re: [VOTE] Release Apache Tomcat 8.5.89
On 12/05/2023 17:46, Christopher Schultz wrote: I'm getting a unit test failure I don't understand: 10-May-2023 22:15:23.192 INFO [main] org.apache.tomcat.util.net.AbstractEndpoint.logCertificate Connector [https-openssl-apr-127.0.0.1-auto-1], TLS virtual host [_default_], certificate type [UNDEFINED] configured from [/home/cschultz/.keystore] using alias [tomcat] and with trust store [/mnt/ephemeral0/cschultz/projects/apache/apache-tomcat/tarball/apache-tomcat-8.5.89-src/test/org/apache/tomcat/util/net/ca-cert.pem] The test is picking up the wrong keystore. It should be something like: /mnt/ephemeral0/cschultz/projects/apache/apache-tomcat/tarball/apache-tomcat-8.5.89-src/test/org/apache/tomcat/util/net/localhost-rsa.jks See the CI logs from the most recent 8.5.x test run for a working example: https://nightlies.apache.org/tomcat/tomcat-8.5.x/logs/486/TEST-org.apache.tomcat.websocket.TestWsWebSocketContainerSSL.NIO.txt No idea how you managed to get the test to pick up the wrong keystore. Mark - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: Tomcat 11 - minimum Java version
On Wed, Jan 11, 2023 at 12:23 PM Mark Thomas wrote: > We would normally make Java 21 the minimum Java version. Given that Java > 21 is still in EA, I don't plan to do that yet. Since the update to Java 21 has now been made and seems to make everyone happy, I would like to discuss Panama. - Panama as it is right now removes the need for tomcat-native 2.0. It is stable, fast enough, works out of the box, is much much better for cloud environments (no funny custom binary to add, only the usual Java), and so on. Actually, all of these statements were already true with Java 17, although the API was a bit rougher. Unfortunately at the moment, it is still preview in Java 21. - It is possible to include the support right now, but since the API would change in Java 22, then Tomcat 11 (or at least that feature) would only target Java 21. Compilation would have to occur on Java 21. - Support for Java 21 ends in 2028. This means then there would be a needed API update to Java LTS.next, dropping support for Java 21 (for that feature), and causing a more complex build (targeting Java 21 with a newer Panama API would cause the compiler to scream). - Multi release JARs are an option, but this is annoying as it would require multiple Java versions to build Tomcat (since it is a preview API), then assemble the multi release JAR. Not looking too good ... Given all this, there are two main options: A) (unfortunately) *not* including the Panama support until it is non preview. Once this happens, then my proposal would be to update the minimum build Java version (not runtime !) for Tomcat 11, add the Panama "final API" support, and use the release option to still target 21 (except for the Panama feature classes, of course, which would be compiled separately). Also as a consequence tomcat-native 2 would have to be supported for the entire lifecycle of Tomcat 11. B) Add full support using Java 21, drop tomcat-native. Once Java LTS.next is released towards the end of 2025 (with non preview Panama, hopefully), update to use the new API. Users of OpenSSL will have to move to Java LTS.next Although I would like B), A) seems more reasonable and in line with our support practices. Comments ? Rémy - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 9.0.x updated: Added NetMaskSet for future use in various filters
This is an automated email from the ASF dual-hosted git repository. isapir pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new 14fb673102 Added NetMaskSet for future use in various filters 14fb673102 is described below commit 14fb6731023007b212cf6d4a3017c884432cff8e Author: Igal Sapir AuthorDate: Fri May 12 18:22:57 2023 -0700 Added NetMaskSet for future use in various filters Logic extracted from RemoteCIDRValve and RemoteCIDRFilter which will be refactored to use the new reusable object to reduce code duplication and follow the DRY principle. Other filters will be able to utilize the new reusable object as well. --- java/org/apache/catalina/util/NetMask.java| 19 +++ java/org/apache/catalina/util/NetMaskSet.java | 147 ++ test/org/apache/catalina/util/TestNetMask.java| 10 ++ test/org/apache/catalina/util/TestNetMaskSet.java | 50 4 files changed, 226 insertions(+) diff --git a/java/org/apache/catalina/util/NetMask.java b/java/org/apache/catalina/util/NetMask.java index bdad9f9de9..b97eee934f 100644 --- a/java/org/apache/catalina/util/NetMask.java +++ b/java/org/apache/catalina/util/NetMask.java @@ -18,6 +18,8 @@ package org.apache.catalina.util; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Arrays; +import java.util.Objects; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -304,4 +306,21 @@ public final class NetMask { public String toString() { return expression; } + +@Override +public boolean equals(Object o) { +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +NetMask other = (NetMask) o; +return nrBytes == other.nrBytes && +lastByteShift == other.lastByteShift && +Arrays.equals(netaddr, other.netaddr); +} + +@Override +public int hashCode() { +int result = 31 * Arrays.hashCode(netaddr) + lastByteShift; +return result; +} + } diff --git a/java/org/apache/catalina/util/NetMaskSet.java b/java/org/apache/catalina/util/NetMaskSet.java new file mode 100644 index 00..4e6b268b8e --- /dev/null +++ b/java/org/apache/catalina/util/NetMaskSet.java @@ -0,0 +1,147 @@ +/* + * 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.catalina.util; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +/** + * This class maintains a Set of NetMask objects and allows to check if + * a given IP address is matched by any of the NetMasks, making it easy + * to create Allow and Deny lists of CIDR networks and hosts. + */ +public class NetMaskSet { + +private final Set netmasks = new HashSet<>(); + +/** + * returns true if the passed inetAddress is matched by any of the {@link NetMask}s in the set + * + * @param inetAddress An InetAddress to check + * @return + */ +public boolean contains(InetAddress inetAddress) { + +for (NetMask nm : netmasks) { +if (nm.matches(inetAddress)) { +return true; +} +} + +return false; +} + +/** + * returns true if the passed inetAddress is matched by any of the {@link NetMask}s in the set + * + * @param ipAddress an IP address to check + * @return + * + * @throws UnknownHostException if the passed input is not a valid IP address + */ +public boolean contains(String ipAddress) throws UnknownHostException { + +InetAddress inetAddress = InetAddress.getByName(ipAddress); +return this.contains(inetAddress); +} + +/** + * adds a NetMask object to the set if the set does not contain it + * + * @param netmask + * @return true if the object was added + */ +public boolean add(NetMask netmask) { +return netmasks.add(netmask); +} + +/** + * creates a
Buildbot failure in on tomcat-9.0.x
Build status: BUILD FAILED: failed compile (failure) Worker used: bb_worker2_ubuntu URL: https://ci2.apache.org/#builders/37/builds/557 Blamelist: Igal Sapir Build Text: failed compile (failure) Status Detected: new failure Build Source Stamp: [branch 9.0.x] 14fb6731023007b212cf6d4a3017c884432cff8e Steps: worker_preparation: 0 git: 0 shell: 0 shell_1: 0 shell_2: 0 shell_3: 0 shell_4: 0 shell_5: 0 compile: 1 shell_6: 0 shell_7: 0 shell_8: 0 shell_9: 0 Rsync docs to nightlies.apache.org: 0 shell_10: 0 Rsync RAT to nightlies.apache.org: 0 compile_1: 2 shell_11: 0 Rsync Logs to nightlies.apache.org: 0 -- ASF Buildbot - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch main updated: Added NetMaskSet for future use in various filters
This is an automated email from the ASF dual-hosted git repository. isapir 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 c09f1f00e6 Added NetMaskSet for future use in various filters c09f1f00e6 is described below commit c09f1f00e609445507bc9bf2b8be07c06c329067 Author: Igal Sapir AuthorDate: Fri May 12 19:19:07 2023 -0700 Added NetMaskSet for future use in various filters Logic extracted from RemoteCIDRValve and RemoteCIDRFilter which will be refactored to use the new reusable object to reduce code duplication and follow the DRY principle. Other filters will be able to utilize the new reusable object as well. --- java/org/apache/catalina/util/NetMask.java| 19 +++ java/org/apache/catalina/util/NetMaskSet.java | 147 ++ test/org/apache/catalina/util/TestNetMask.java| 10 ++ test/org/apache/catalina/util/TestNetMaskSet.java | 50 4 files changed, 226 insertions(+) diff --git a/java/org/apache/catalina/util/NetMask.java b/java/org/apache/catalina/util/NetMask.java index bdad9f9de9..b97eee934f 100644 --- a/java/org/apache/catalina/util/NetMask.java +++ b/java/org/apache/catalina/util/NetMask.java @@ -18,6 +18,8 @@ package org.apache.catalina.util; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Arrays; +import java.util.Objects; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -304,4 +306,21 @@ public final class NetMask { public String toString() { return expression; } + +@Override +public boolean equals(Object o) { +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +NetMask other = (NetMask) o; +return nrBytes == other.nrBytes && +lastByteShift == other.lastByteShift && +Arrays.equals(netaddr, other.netaddr); +} + +@Override +public int hashCode() { +int result = 31 * Arrays.hashCode(netaddr) + lastByteShift; +return result; +} + } diff --git a/java/org/apache/catalina/util/NetMaskSet.java b/java/org/apache/catalina/util/NetMaskSet.java new file mode 100644 index 00..4e6b268b8e --- /dev/null +++ b/java/org/apache/catalina/util/NetMaskSet.java @@ -0,0 +1,147 @@ +/* + * 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.catalina.util; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +/** + * This class maintains a Set of NetMask objects and allows to check if + * a given IP address is matched by any of the NetMasks, making it easy + * to create Allow and Deny lists of CIDR networks and hosts. + */ +public class NetMaskSet { + +private final Set netmasks = new HashSet<>(); + +/** + * returns true if the passed inetAddress is matched by any of the {@link NetMask}s in the set + * + * @param inetAddress An InetAddress to check + * @return + */ +public boolean contains(InetAddress inetAddress) { + +for (NetMask nm : netmasks) { +if (nm.matches(inetAddress)) { +return true; +} +} + +return false; +} + +/** + * returns true if the passed inetAddress is matched by any of the {@link NetMask}s in the set + * + * @param ipAddress an IP address to check + * @return + * + * @throws UnknownHostException if the passed input is not a valid IP address + */ +public boolean contains(String ipAddress) throws UnknownHostException { + +InetAddress inetAddress = InetAddress.getByName(ipAddress); +return this.contains(inetAddress); +} + +/** + * adds a NetMask object to the set if the set does not contain it + * + * @param netmask + * @return true if the object was added + */ +public boolean add(NetMask netmask) { +return netmasks.add(netmask); +} + +/** + * creates a N
[tomcat] branch 10.1.x updated: Added NetMaskSet for future use in various filters
This is an automated email from the ASF dual-hosted git repository. isapir pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.1.x by this push: new 3ee6695378 Added NetMaskSet for future use in various filters 3ee6695378 is described below commit 3ee66953788fbc91dcd2392e07c1ff9ffd61a9f6 Author: Igal Sapir AuthorDate: Fri May 12 19:40:18 2023 -0700 Added NetMaskSet for future use in various filters Logic extracted from RemoteCIDRValve and RemoteCIDRFilter which will be refactored to use the new reusable object to reduce code duplication and follow the DRY principle. Other filters will be able to utilize the new reusable object as well. --- java/org/apache/catalina/util/NetMask.java| 19 +++ java/org/apache/catalina/util/NetMaskSet.java | 147 ++ test/org/apache/catalina/util/TestNetMask.java| 10 ++ test/org/apache/catalina/util/TestNetMaskSet.java | 50 4 files changed, 226 insertions(+) diff --git a/java/org/apache/catalina/util/NetMask.java b/java/org/apache/catalina/util/NetMask.java index bdad9f9de9..b97eee934f 100644 --- a/java/org/apache/catalina/util/NetMask.java +++ b/java/org/apache/catalina/util/NetMask.java @@ -18,6 +18,8 @@ package org.apache.catalina.util; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Arrays; +import java.util.Objects; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -304,4 +306,21 @@ public final class NetMask { public String toString() { return expression; } + +@Override +public boolean equals(Object o) { +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +NetMask other = (NetMask) o; +return nrBytes == other.nrBytes && +lastByteShift == other.lastByteShift && +Arrays.equals(netaddr, other.netaddr); +} + +@Override +public int hashCode() { +int result = 31 * Arrays.hashCode(netaddr) + lastByteShift; +return result; +} + } diff --git a/java/org/apache/catalina/util/NetMaskSet.java b/java/org/apache/catalina/util/NetMaskSet.java new file mode 100644 index 00..4e6b268b8e --- /dev/null +++ b/java/org/apache/catalina/util/NetMaskSet.java @@ -0,0 +1,147 @@ +/* + * 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.catalina.util; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +/** + * This class maintains a Set of NetMask objects and allows to check if + * a given IP address is matched by any of the NetMasks, making it easy + * to create Allow and Deny lists of CIDR networks and hosts. + */ +public class NetMaskSet { + +private final Set netmasks = new HashSet<>(); + +/** + * returns true if the passed inetAddress is matched by any of the {@link NetMask}s in the set + * + * @param inetAddress An InetAddress to check + * @return + */ +public boolean contains(InetAddress inetAddress) { + +for (NetMask nm : netmasks) { +if (nm.matches(inetAddress)) { +return true; +} +} + +return false; +} + +/** + * returns true if the passed inetAddress is matched by any of the {@link NetMask}s in the set + * + * @param ipAddress an IP address to check + * @return + * + * @throws UnknownHostException if the passed input is not a valid IP address + */ +public boolean contains(String ipAddress) throws UnknownHostException { + +InetAddress inetAddress = InetAddress.getByName(ipAddress); +return this.contains(inetAddress); +} + +/** + * adds a NetMask object to the set if the set does not contain it + * + * @param netmask + * @return true if the object was added + */ +public boolean add(NetMask netmask) { +return netmasks.add(netmask); +} + +/** + * creat
[tomcat] branch 8.5.x updated: Added NetMaskSet for future use in various filters
This is an automated email from the ASF dual-hosted git repository. isapir pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new 65551881bb Added NetMaskSet for future use in various filters 65551881bb is described below commit 65551881bb64278d005930b7d376f1f6e69a85ef Author: Igal Sapir AuthorDate: Fri May 12 19:52:38 2023 -0700 Added NetMaskSet for future use in various filters Logic extracted from RemoteCIDRValve and RemoteCIDRFilter which will be refactored to use the new reusable object to reduce code duplication and follow the DRY principle. Other filters will be able to utilize the new reusable object as well. --- java/org/apache/catalina/util/NetMask.java| 19 +++ java/org/apache/catalina/util/NetMaskSet.java | 147 ++ test/org/apache/catalina/util/TestNetMask.java| 10 ++ test/org/apache/catalina/util/TestNetMaskSet.java | 50 4 files changed, 226 insertions(+) diff --git a/java/org/apache/catalina/util/NetMask.java b/java/org/apache/catalina/util/NetMask.java index bdad9f9de9..b97eee934f 100644 --- a/java/org/apache/catalina/util/NetMask.java +++ b/java/org/apache/catalina/util/NetMask.java @@ -18,6 +18,8 @@ package org.apache.catalina.util; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Arrays; +import java.util.Objects; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -304,4 +306,21 @@ public final class NetMask { public String toString() { return expression; } + +@Override +public boolean equals(Object o) { +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +NetMask other = (NetMask) o; +return nrBytes == other.nrBytes && +lastByteShift == other.lastByteShift && +Arrays.equals(netaddr, other.netaddr); +} + +@Override +public int hashCode() { +int result = 31 * Arrays.hashCode(netaddr) + lastByteShift; +return result; +} + } diff --git a/java/org/apache/catalina/util/NetMaskSet.java b/java/org/apache/catalina/util/NetMaskSet.java new file mode 100644 index 00..4e6b268b8e --- /dev/null +++ b/java/org/apache/catalina/util/NetMaskSet.java @@ -0,0 +1,147 @@ +/* + * 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.catalina.util; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +/** + * This class maintains a Set of NetMask objects and allows to check if + * a given IP address is matched by any of the NetMasks, making it easy + * to create Allow and Deny lists of CIDR networks and hosts. + */ +public class NetMaskSet { + +private final Set netmasks = new HashSet<>(); + +/** + * returns true if the passed inetAddress is matched by any of the {@link NetMask}s in the set + * + * @param inetAddress An InetAddress to check + * @return + */ +public boolean contains(InetAddress inetAddress) { + +for (NetMask nm : netmasks) { +if (nm.matches(inetAddress)) { +return true; +} +} + +return false; +} + +/** + * returns true if the passed inetAddress is matched by any of the {@link NetMask}s in the set + * + * @param ipAddress an IP address to check + * @return + * + * @throws UnknownHostException if the passed input is not a valid IP address + */ +public boolean contains(String ipAddress) throws UnknownHostException { + +InetAddress inetAddress = InetAddress.getByName(ipAddress); +return this.contains(inetAddress); +} + +/** + * adds a NetMask object to the set if the set does not contain it + * + * @param netmask + * @return true if the object was added + */ +public boolean add(NetMask netmask) { +return netmasks.add(netmask); +} + +/** + * creates