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 2023/02/27 17:02:14 UTC
[tomcat] 03/03: Follow up to reverting custom URL handler for war
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
commit 0dda748db209a2e8eefd6d19bef22d8ec09ab346
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Feb 27 16:44:01 2023 +0000
Follow up to reverting custom URL handler for war
Reviewed 9.0.x / 10.0.x / 11.0.x diff and aligned code
---
build.xml | 3 +-
.../TomcatURLStreamHandlerFactory.java | 44 ++++++++--------------
2 files changed, 17 insertions(+), 30 deletions(-)
diff --git a/build.xml b/build.xml
index 9070c52281..123b6002ce 100644
--- a/build.xml
+++ b/build.xml
@@ -103,7 +103,7 @@
<!-- build output directory for generated reflectionless code -->
<property name="tomcat.xreflect" value="${tomcat.output}/xreflect"/>
- <!-- Jakarta EE 10 platform requires Java 11+ -->
+ <!-- Jakarta EE 11 platform requires Java 21+ -->
<!-- Keep in sync with webapps/docs/tomcat-docs.xsl -->
<property name="compile.release" value="17"/>
<property name="min.java.version" value="17"/>
@@ -297,7 +297,6 @@
<include name="**/jakarta.servlet.ServletContainerInitializer"/>
<include name="**/jakarta.websocket.ContainerProvider"/>
<include name="**/jakarta.websocket.server.ServerEndpointConfig$Configurator"/>
- <include name="**/java.net.spi.URLStreamHandlerProvider"/>
<include name="**/.gitignore"/>
<include name="**/*.bnd"/>
<include name="**/*.classpath"/>
diff --git a/java/org/apache/catalina/webresources/TomcatURLStreamHandlerFactory.java b/java/org/apache/catalina/webresources/TomcatURLStreamHandlerFactory.java
index d58f9d3fef..02a0842eea 100644
--- a/java/org/apache/catalina/webresources/TomcatURLStreamHandlerFactory.java
+++ b/java/org/apache/catalina/webresources/TomcatURLStreamHandlerFactory.java
@@ -33,9 +33,8 @@ public class TomcatURLStreamHandlerFactory implements URLStreamHandlerFactory {
private static volatile TomcatURLStreamHandlerFactory instance = null;
/**
- * Obtain a reference to the singleton instance. It is recommended that
- * callers check the value of {@link #isRegistered()} before using the
- * returned instance.
+ * Obtain a reference to the singleton instance. It is recommended that callers check the value of
+ * {@link #isRegistered()} before using the returned instance.
*
* @return A reference to the singleton instance
*/
@@ -61,17 +60,14 @@ public class TomcatURLStreamHandlerFactory implements URLStreamHandlerFactory {
private final boolean registered;
// List of factories for application defined stream handler factories.
- private final List<URLStreamHandlerFactory> userFactories =
- new CopyOnWriteArrayList<>();
+ private final List<URLStreamHandlerFactory> userFactories = new CopyOnWriteArrayList<>();
/**
- * Register this factory with the JVM. May be called more than once. The
- * implementation ensures that registration only occurs once.
+ * Register this factory with the JVM. May be called more than once. The implementation ensures that registration
+ * only occurs once.
*
- * @return <code>true</code> if the factory is already registered with the
- * JVM or was successfully registered as a result of this call.
- * <code>false</code> if the factory was disabled prior to this
- * call.
+ * @return <code>true</code> if the factory is already registered with the JVM or was successfully registered as a
+ * result of this call. <code>false</code> if the factory was disabled prior to this call.
*/
public static boolean register() {
return getInstanceInternal(true).isRegistered();
@@ -79,13 +75,10 @@ public class TomcatURLStreamHandlerFactory implements URLStreamHandlerFactory {
/**
- * Prevent this this factory from registering with the JVM. May be called
- * more than once.
+ * Prevent this this factory from registering with the JVM. May be called more than once.
*
- * @return <code>true</code> if the factory is already disabled or was
- * successfully disabled as a result of this call.
- * <code>false</code> if the factory was already registered prior
- * to this call.
+ * @return <code>true</code> if the factory is already disabled or was successfully disabled as a result of this
+ * call. <code>false</code> if the factory was already registered prior to this call.
*/
public static boolean disable() {
return !getInstanceInternal(false).isRegistered();
@@ -93,9 +86,8 @@ public class TomcatURLStreamHandlerFactory implements URLStreamHandlerFactory {
/**
- * Release references to any user provided factories that have been loaded
- * using the provided class loader. Called during web application stop to
- * prevent memory leaks.
+ * Release references to any user provided factories that have been loaded using the provided class loader. Called
+ * during web application stop to prevent memory leaks.
*
* @param classLoader The class loader to release
*/
@@ -137,13 +129,10 @@ public class TomcatURLStreamHandlerFactory implements URLStreamHandlerFactory {
/**
- * Since the JVM only allows a single call to
- * {@link URL#setURLStreamHandlerFactory(URLStreamHandlerFactory)} and
- * Tomcat needs to register a handler, provide a mechanism to allow
- * applications to register their own handlers.
+ * Since the JVM only allows a single call to {@link URL#setURLStreamHandlerFactory(URLStreamHandlerFactory)} and
+ * Tomcat needs to register a handler, provide a mechanism to allow applications to register their own handlers.
*
- * @param factory The user provided factory to add to the factories Tomcat
- * has already registered
+ * @param factory The user provided factory to add to the factories Tomcat has already registered
*/
public void addUserFactory(URLStreamHandlerFactory factory) {
userFactories.add(factory);
@@ -163,8 +152,7 @@ public class TomcatURLStreamHandlerFactory implements URLStreamHandlerFactory {
// Application handlers
for (URLStreamHandlerFactory factory : userFactories) {
- URLStreamHandler handler =
- factory.createURLStreamHandler(protocol);
+ URLStreamHandler handler = factory.createURLStreamHandler(protocol);
if (handler != null) {
return handler;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org