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 42dbc1fb87 Code clean-up - formatting. No functional change.
42dbc1fb87 is described below
commit 42dbc1fb87c1078ac882b5fd8f9e7de1ad0637f6
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Aug 29 12:04:56 2025 +0100
Code clean-up - formatting. No functional change.
---
java/org/apache/tomcat/ContextBind.java | 33 +++++-------
java/org/apache/tomcat/InstanceManager.java | 26 ++++------
.../org/apache/tomcat/InstanceManagerBindings.java | 4 +-
.../apache/tomcat/InstrumentableClassLoader.java | 50 +++++++-----------
java/org/apache/tomcat/Jar.java | 59 +++++++++-------------
java/org/apache/tomcat/JarScanFilter.java | 16 +++---
java/org/apache/tomcat/JarScanner.java | 22 ++++----
java/org/apache/tomcat/JarScannerCallback.java | 31 +++++-------
java/org/apache/tomcat/SimpleInstanceManager.java | 18 +++----
9 files changed, 108 insertions(+), 151 deletions(-)
diff --git a/java/org/apache/tomcat/ContextBind.java
b/java/org/apache/tomcat/ContextBind.java
index 920c6dbfd5..93b32f81fd 100644
--- a/java/org/apache/tomcat/ContextBind.java
+++ b/java/org/apache/tomcat/ContextBind.java
@@ -19,34 +19,25 @@ package org.apache.tomcat;
public interface ContextBind {
/**
- * Change the current thread context class loader to the web application
- * class loader. If no web application class loader is defined, or if the
- * current thread is already using the web application class loader then no
- * change will be made. If the class loader is changed and a
- * {@link org.apache.catalina.ThreadBindingListener} is configured then
- * {@link org.apache.catalina.ThreadBindingListener#bind()} will be called
- * after the change has been made.
+ * Change the current thread context class loader to the web application
class loader. If no web application class
+ * loader is defined, or if the current thread is already using the web
application class loader then no change will
+ * be made. If the class loader is changed and a {@link
org.apache.catalina.ThreadBindingListener} is configured
+ * then {@link org.apache.catalina.ThreadBindingListener#bind()} will be
called after the change has been made.
*
- * @param originalClassLoader The current class loader if known to save
this
- * method having to look it up
+ * @param originalClassLoader The current class loader if known to save
this method having to look it up
*
- * @return If the class loader has been changed by the method it will
return
- * the thread context class loader in use when the method was called.
If
- * no change was made then this method returns null.
+ * @return If the class loader has been changed by the method it will
return the thread context class loader in use
+ * when the method was called. If no change was made then this
method returns null.
*/
ClassLoader bind(ClassLoader originalClassLoader);
/**
- * Restore the current thread context class loader to the original class
- * loader in use before {@link #bind(ClassLoader)} was called. If
- * no original class loader is passed to this method then no change will be
- * made. If the class loader is changed and a
- * {@link org.apache.catalina.ThreadBindingListener} is configured then
- * {@link org.apache.catalina.ThreadBindingListener#unbind()} will be
called
- * before the change is made.
+ * Restore the current thread context class loader to the original class
loader in use before
+ * {@link #bind(ClassLoader)} was called. If no original class loader is
passed to this method then no change will
+ * be made. If the class loader is changed and a {@link
org.apache.catalina.ThreadBindingListener} is configured
+ * then {@link org.apache.catalina.ThreadBindingListener#unbind()} will be
called before the change is made.
*
- * @param originalClassLoader
- * The class loader to restore as the thread context class loader
+ * @param originalClassLoader The class loader to restore as the thread
context class loader
*/
void unbind(ClassLoader originalClassLoader);
}
diff --git a/java/org/apache/tomcat/InstanceManager.java
b/java/org/apache/tomcat/InstanceManager.java
index 978eb8de52..0a31b643c6 100644
--- a/java/org/apache/tomcat/InstanceManager.java
+++ b/java/org/apache/tomcat/InstanceManager.java
@@ -22,28 +22,24 @@ import javax.naming.NamingException;
public interface InstanceManager {
- Object newInstance(Class<?> clazz) throws IllegalAccessException,
InvocationTargetException,
- NamingException, InstantiationException, IllegalArgumentException,
- NoSuchMethodException, SecurityException;
+ Object newInstance(Class<?> clazz) throws IllegalAccessException,
InvocationTargetException, NamingException,
+ InstantiationException, IllegalArgumentException,
NoSuchMethodException, SecurityException;
- Object newInstance(String className) throws IllegalAccessException,
InvocationTargetException,
- NamingException, InstantiationException, ClassNotFoundException,
- IllegalArgumentException, NoSuchMethodException, SecurityException;
+ Object newInstance(String className)
+ throws IllegalAccessException, InvocationTargetException,
NamingException, InstantiationException,
+ ClassNotFoundException, IllegalArgumentException,
NoSuchMethodException, SecurityException;
- Object newInstance(String fqcn, ClassLoader classLoader) throws
IllegalAccessException,
- InvocationTargetException, NamingException, InstantiationException,
- ClassNotFoundException, IllegalArgumentException,
NoSuchMethodException,
- SecurityException;
+ Object newInstance(String fqcn, ClassLoader classLoader)
+ throws IllegalAccessException, InvocationTargetException,
NamingException, InstantiationException,
+ ClassNotFoundException, IllegalArgumentException,
NoSuchMethodException, SecurityException;
- void newInstance(Object o)
- throws IllegalAccessException, InvocationTargetException,
NamingException;
+ void newInstance(Object o) throws IllegalAccessException,
InvocationTargetException, NamingException;
void destroyInstance(Object o) throws IllegalAccessException,
InvocationTargetException;
/**
- * Called by the component using the InstanceManager periodically to
perform
- * any regular maintenance that might be required. By default, this method
- * is a NO-OP.
+ * Called by the component using the InstanceManager periodically to
perform any regular maintenance that might be
+ * required. By default, this method is a NO-OP.
*/
default void backgroundProcess() {
// NO-OP by default
diff --git a/java/org/apache/tomcat/InstanceManagerBindings.java
b/java/org/apache/tomcat/InstanceManagerBindings.java
index 7b22eb3228..543b598a28 100644
--- a/java/org/apache/tomcat/InstanceManagerBindings.java
+++ b/java/org/apache/tomcat/InstanceManagerBindings.java
@@ -21,14 +21,16 @@ import java.util.concurrent.ConcurrentHashMap;
public final class InstanceManagerBindings {
- private static final Map<ClassLoader, InstanceManager> bindings = new
ConcurrentHashMap<>();
+ private static final Map<ClassLoader,InstanceManager> bindings = new
ConcurrentHashMap<>();
public static void bind(ClassLoader classLoader, InstanceManager
instanceManager) {
bindings.put(classLoader, instanceManager);
}
+
public static void unbind(ClassLoader classLoader) {
bindings.remove(classLoader);
}
+
public static InstanceManager get(ClassLoader classLoader) {
return bindings.get(classLoader);
}
diff --git a/java/org/apache/tomcat/InstrumentableClassLoader.java
b/java/org/apache/tomcat/InstrumentableClassLoader.java
index d2e18dc701..4f798b1f93 100644
--- a/java/org/apache/tomcat/InstrumentableClassLoader.java
+++ b/java/org/apache/tomcat/InstrumentableClassLoader.java
@@ -19,58 +19,46 @@ package org.apache.tomcat;
import java.lang.instrument.ClassFileTransformer;
/**
- * Specifies a class loader capable of being decorated with
- * {@link ClassFileTransformer}s. These transformers can instrument
- * (or weave) the byte code of classes loaded through this class loader
- * to alter their behavior. Currently only
- * {@link org.apache.catalina.loader.WebappClassLoaderBase} implements this
- * interface. This allows web application frameworks or JPA providers
- * bundled with a web application to instrument web application classes
- * as necessary.
+ * Specifies a class loader capable of being decorated with {@link
ClassFileTransformer}s. These transformers can
+ * instrument (or weave) the byte code of classes loaded through this class
loader to alter their behavior. Currently
+ * only {@link org.apache.catalina.loader.WebappClassLoaderBase} implements
this interface. This allows web application
+ * frameworks or JPA providers bundled with a web application to instrument
web application classes as necessary.
* <p>
- * You should always program against the methods of this interface
- * (whether using reflection or otherwise). The methods in
- * {@code WebappClassLoaderBase} are protected by the default security
- * manager if one is in use.
+ * You should always program against the methods of this interface (whether
using reflection or otherwise). The methods
+ * in {@code WebappClassLoaderBase} are protected by the default security
manager if one is in use.
*
* @since 8.0, 7.0.64
*/
public interface InstrumentableClassLoader {
/**
- * Adds the specified class file transformer to this class loader. The
- * transformer will then be able to instrument the bytecode of any
- * classes loaded by this class loader after the invocation of this
- * method.
+ * Adds the specified class file transformer to this class loader. The
transformer will then be able to instrument
+ * the bytecode of any classes loaded by this class loader after the
invocation of this method.
*
* @param transformer The transformer to add to the class loader
+ *
* @throws IllegalArgumentException if the {@literal transformer} is null.
*/
void addTransformer(ClassFileTransformer transformer);
/**
- * Removes the specified class file transformer from this class loader.
- * It will no longer be able to instrument the byte code of any classes
- * loaded by the class loader after the invocation of this method.
- * However, any classes already instrumented by this transformer before
- * this method call will remain in their instrumented state.
+ * Removes the specified class file transformer from this class loader. It
will no longer be able to instrument the
+ * byte code of any classes loaded by the class loader after the
invocation of this method. However, any classes
+ * already instrumented by this transformer before this method call will
remain in their instrumented state.
*
* @param transformer The transformer to remove
*/
void removeTransformer(ClassFileTransformer transformer);
/**
- * Returns a copy of this class loader without any class file
- * transformers. This is a tool often used by Java Persistence API
- * providers to inspect entity classes in the absence of any
- * instrumentation, something that can't be guaranteed within the
- * context of a {@link ClassFileTransformer}'s
- * {@link ClassFileTransformer#transform(ClassLoader, String, Class,
- * java.security.ProtectionDomain, byte[]) transform} method.
+ * Returns a copy of this class loader without any class file
transformers. This is a tool often used by Java
+ * Persistence API providers to inspect entity classes in the absence of
any instrumentation, something that can't
+ * be guaranteed within the context of a {@link ClassFileTransformer}'s
+ * {@link ClassFileTransformer#transform(ClassLoader, String, Class,
java.security.ProtectionDomain, byte[])
+ * transform} method.
* <p>
- * The returned class loader's resource cache will have been cleared
- * so that classes already instrumented will not be retained or
- * returned.
+ * The returned class loader's resource cache will have been cleared so
that classes already instrumented will not
+ * be retained or returned.
*
* @return the transformer-free copy of this class loader.
*/
diff --git a/java/org/apache/tomcat/Jar.java b/java/org/apache/tomcat/Jar.java
index 341e86b340..6bb7226790 100644
--- a/java/org/apache/tomcat/Jar.java
+++ b/java/org/apache/tomcat/Jar.java
@@ -22,15 +22,12 @@ import java.net.URL;
import java.util.jar.Manifest;
/**
- * Provides an abstraction for use by the various classes that need to scan
- * JARs. The classes provided by the JRE for accessing JARs
- * ({@link java.util.jar.JarFile} and {@link java.util.jar.JarInputStream})
have
- * significantly different performance characteristics depending on the form of
- * the URL used to access the JAR. For file based JAR {@link java.net.URL}s,
- * {@link java.util.jar.JarFile} is faster but for non-file based
- * {@link java.net.URL}s, {@link java.util.jar.JarFile} creates a copy of the
- * JAR in the temporary directory so {@link java.util.jar.JarInputStream} is
- * faster.
+ * Provides an abstraction for use by the various classes that need to scan
JARs. The classes provided by the JRE for
+ * accessing JARs ({@link java.util.jar.JarFile} and {@link
java.util.jar.JarInputStream}) have significantly different
+ * performance characteristics depending on the form of the URL used to access
the JAR. For file based JAR
+ * {@link java.net.URL}s, {@link java.util.jar.JarFile} is faster but for
non-file based {@link java.net.URL}s,
+ * {@link java.util.jar.JarFile} creates a copy of the JAR in the temporary
directory so
+ * {@link java.util.jar.JarInputStream} is faster.
*/
public interface Jar extends AutoCloseable {
@@ -40,12 +37,11 @@ public interface Jar extends AutoCloseable {
URL getJarFileURL();
/**
- * Obtain an {@link InputStream} for a given entry in a JAR. The caller is
- * responsible for closing the stream.
+ * Obtain an {@link InputStream} for a given entry in a JAR. The caller is
responsible for closing the stream.
*
- * @param name Entry to obtain an {@link InputStream} for
- * @return An {@link InputStream} for the specified entry or null if
- * the entry does not exist
+ * @param name Entry to obtain an {@link InputStream} for
+ *
+ * @return An {@link InputStream} for the specified entry or null if the
entry does not exist
*
* @throws IOException if an I/O error occurs while processing the JAR file
*/
@@ -54,11 +50,10 @@ public interface Jar extends AutoCloseable {
/**
* Obtain the last modified time for the given resource in the JAR.
*
- * @param name Entry to obtain the modification time for
+ * @param name Entry to obtain the modification time for
*
- * @return The time (in the same format as
- * {@link System#currentTimeMillis()}) that the resource was last
- * modified. Returns -1 if the entry does not exist
+ * @return The time (in the same format as {@link
System#currentTimeMillis()}) that the resource was last modified.
+ * Returns -1 if the entry does not exist
*
* @throws IOException if an I/O error occurs while processing the JAR file
*/
@@ -67,10 +62,9 @@ public interface Jar extends AutoCloseable {
/**
* Determine if the given resource in present in the JAR.
*
- * @param name Entry to look for
+ * @param name Entry to look for
*
- * @return {@code true} if the entry is present in the JAR, otherwise
- * {@code false}
+ * @return {@code true} if the entry is present in the JAR, otherwise
{@code false}
*
* @throws IOException if an I/O error occurs while processing the JAR file
*/
@@ -90,26 +84,24 @@ public interface Jar extends AutoCloseable {
/**
* Obtains the name of the current entry.
*
- * @return The entry name
+ * @return The entry name
*/
String getEntryName();
/**
* Obtains the input stream for the current entry.
*
- * @return The input stream
- * @throws IOException If the stream cannot be obtained
+ * @return The input stream
+ *
+ * @throws IOException If the stream cannot be obtained
*/
InputStream getEntryInputStream() throws IOException;
/**
- * Obtain, in String form, the URL for an entry in this JAR. Note that for
- * JARs nested in WAR files, the Tomcat specific war:file:... form will not
- * be used, rather the jar:jar:file:... form (that the JRE does not
- * understand will be used). Note that this means that any code using these
- * URLs will need to understand the jar:jar:file:... form and use the
- * {@link org.apache.tomcat.util.scan.JarFactory} to ensure resources are
- * accessed correctly.
+ * Obtain, in String form, the URL for an entry in this JAR. Note that for
JARs nested in WAR files, the Tomcat
+ * specific war:file:... form will not be used, rather the
jar:jar:file:... form (that the JRE does not understand
+ * will be used). Note that this means that any code using these URLs will
need to understand the jar:jar:file:...
+ * form and use the {@link org.apache.tomcat.util.scan.JarFactory} to
ensure resources are accessed correctly.
*
* @param entry The entry to generate the URL for
*
@@ -127,10 +119,9 @@ public interface Jar extends AutoCloseable {
Manifest getManifest() throws IOException;
/**
- * Resets the internal pointer used to track JAR entries to the beginning
of
- * the JAR.
+ * Resets the internal pointer used to track JAR entries to the beginning
of the JAR.
*
- * @throws IOException If the pointer cannot be reset
+ * @throws IOException If the pointer cannot be reset
*/
void reset() throws IOException;
}
diff --git a/java/org/apache/tomcat/JarScanFilter.java
b/java/org/apache/tomcat/JarScanFilter.java
index f616fe46fc..6bca798a7c 100644
--- a/java/org/apache/tomcat/JarScanFilter.java
+++ b/java/org/apache/tomcat/JarScanFilter.java
@@ -19,18 +19,18 @@ package org.apache.tomcat;
public interface JarScanFilter {
/**
- * @param jarScanType The type of JAR scan currently being performed
- * @param jarName The name of the JAR file (without any path
- * information) to be checked to see if it should
- * be included in the results or not
- * @return <code>true</code> if the JAR should be returned in the results,
- * <code>false</code> if it should be excluded
+ * @param jarScanType The type of JAR scan currently being performed
+ * @param jarName The name of the JAR file (without any path
information) to be checked to see if it should be
+ * included in the results or not
+ *
+ * @return <code>true</code> if the JAR should be returned in the results,
<code>false</code> if it should be
+ * excluded
*/
boolean check(JarScanType jarScanType, String jarName);
/**
- * @return <code>true</code> if all of the scans should be skipped which
- * can improve startup performance. The default is <code>false</code>.
+ * @return <code>true</code> if all of the scans should be skipped which
can improve startup performance. The
+ * default is <code>false</code>.
*/
default boolean isSkipAll() {
return false;
diff --git a/java/org/apache/tomcat/JarScanner.java
b/java/org/apache/tomcat/JarScanner.java
index f92e78fe36..9747070952 100644
--- a/java/org/apache/tomcat/JarScanner.java
+++ b/java/org/apache/tomcat/JarScanner.java
@@ -19,25 +19,21 @@ package org.apache.tomcat;
import jakarta.servlet.ServletContext;
/**
- * Scans a web application and classloader hierarchy for JAR files. Uses
- * include TLD scanning and web-fragment.xml scanning. Uses a call-back
- * mechanism so the caller can process each JAR found.
+ * Scans a web application and classloader hierarchy for JAR files. Uses
include TLD scanning and web-fragment.xml
+ * scanning. Uses a call-back mechanism so the caller can process each JAR
found.
*/
public interface JarScanner {
/**
- * Scan the provided ServletContext and classloader for JAR files. Each JAR
- * file found will be passed to the callback handler to be processed.
+ * Scan the provided ServletContext and classloader for JAR files. Each
JAR file found will be passed to the
+ * callback handler to be processed.
*
- * @param scanType The type of JAR scan to perform. This is passed to
- * the filter which uses it to determine how to
- * filter the results
- * @param context The ServletContext - used to locate and access
- * WEB-INF/lib
- * @param callback The handler to process any JARs found
+ * @param scanType The type of JAR scan to perform. This is passed to the
filter which uses it to determine how to
+ * filter the results
+ * @param context The ServletContext - used to locate and access
WEB-INF/lib
+ * @param callback The handler to process any JARs found
*/
- void scan(JarScanType scanType, ServletContext context,
- JarScannerCallback callback);
+ void scan(JarScanType scanType, ServletContext context, JarScannerCallback
callback);
JarScanFilter getJarScanFilter();
diff --git a/java/org/apache/tomcat/JarScannerCallback.java
b/java/org/apache/tomcat/JarScannerCallback.java
index 92669cf3ef..09982a7fc1 100644
--- a/java/org/apache/tomcat/JarScannerCallback.java
+++ b/java/org/apache/tomcat/JarScannerCallback.java
@@ -20,35 +20,31 @@ import java.io.File;
import java.io.IOException;
/**
- * This interface is implemented by clients of the {@link JarScanner} to enable
- * them to receive notification of a discovered JAR.
+ * This interface is implemented by clients of the {@link JarScanner} to
enable them to receive notification of a
+ * discovered JAR.
*/
public interface JarScannerCallback {
/**
- * A JAR was found and may be accessed for further processing via the
- * provided URL connection. The caller is responsible for closing the JAR.
+ * A JAR was found and may be accessed for further processing via the
provided URL connection. The caller is
+ * responsible for closing the JAR.
*
* @param jar The JAR to process
* @param webappPath The path, if any, to the JAR within the web
application
- * @param isWebapp Indicates if the JAR was found within a web
- * application. If <code>false</code> the JAR should
+ * @param isWebapp Indicates if the JAR was found within a web
application. If <code>false</code> the JAR should
* be treated as being provided by the container
*
* @throws IOException if an I/O error occurs while scanning the JAR
*/
- void scan(Jar jar, String webappPath, boolean isWebapp)
- throws IOException;
+ void scan(Jar jar, String webappPath, boolean isWebapp) throws IOException;
/**
- * A directory was found that is to be treated as an unpacked JAR. The
- * directory may be accessed for further processing via the provided file.
+ * A directory was found that is to be treated as an unpacked JAR. The
directory may be accessed for further
+ * processing via the provided file.
*
* @param file The directory containing the unpacked JAR.
- * @param webappPath The path, if any, to the file within the web
- * application
- * @param isWebapp Indicates if the JAR was found within a web
- * application. If <code>false</code> the JAR should
+ * @param webappPath The path, if any, to the file within the web
application
+ * @param isWebapp Indicates if the JAR was found within a web
application. If <code>false</code> the JAR should
* be treated as being provided by the container
*
* @throws IOException if an I/O error occurs while scanning the JAR
@@ -56,10 +52,9 @@ public interface JarScannerCallback {
void scan(File file, String webappPath, boolean isWebapp) throws
IOException;
/**
- * A directory structure was found within the web application at
- * /WEB-INF/classes that should be handled as an unpacked JAR. Note that
all
- * resource access must be via the ServletContext to ensure that any
- * additional resources are visible.
+ * A directory structure was found within the web application at
/WEB-INF/classes that should be handled as an
+ * unpacked JAR. Note that all resource access must be via the
ServletContext to ensure that any additional
+ * resources are visible.
*
* @throws IOException if an I/O error occurs while scanning
WEB-INF/classes
*/
diff --git a/java/org/apache/tomcat/SimpleInstanceManager.java
b/java/org/apache/tomcat/SimpleInstanceManager.java
index 15133a5385..b0a711d16a 100644
--- a/java/org/apache/tomcat/SimpleInstanceManager.java
+++ b/java/org/apache/tomcat/SimpleInstanceManager.java
@@ -29,30 +29,28 @@ public class SimpleInstanceManager implements
InstanceManager {
}
@Override
- public Object newInstance(Class<?> clazz) throws IllegalAccessException,
- InvocationTargetException, NamingException,
InstantiationException, NoSuchMethodException {
+ public Object newInstance(Class<?> clazz) throws IllegalAccessException,
InvocationTargetException, NamingException,
+ InstantiationException, NoSuchMethodException {
return prepareInstance(clazz.getConstructor().newInstance());
}
@Override
- public Object newInstance(String className) throws IllegalAccessException,
- InvocationTargetException, NamingException, InstantiationException,
- ClassNotFoundException, NoSuchMethodException {
+ public Object newInstance(String className) throws IllegalAccessException,
InvocationTargetException,
+ NamingException, InstantiationException, ClassNotFoundException,
NoSuchMethodException {
Class<?> clazz =
Thread.currentThread().getContextClassLoader().loadClass(className);
return prepareInstance(clazz.getConstructor().newInstance());
}
@Override
- public Object newInstance(String fqcn, ClassLoader classLoader) throws
IllegalAccessException,
- InvocationTargetException, NamingException, InstantiationException,
- ClassNotFoundException, NoSuchMethodException {
+ public Object newInstance(String fqcn, ClassLoader classLoader)
+ throws IllegalAccessException, InvocationTargetException,
NamingException, InstantiationException,
+ ClassNotFoundException, NoSuchMethodException {
Class<?> clazz = classLoader.loadClass(fqcn);
return prepareInstance(clazz.getConstructor().newInstance());
}
@Override
- public void newInstance(Object o) throws IllegalAccessException,
InvocationTargetException,
- NamingException {
+ public void newInstance(Object o) throws IllegalAccessException,
InvocationTargetException, NamingException {
// NO-OP
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]