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 ea7c2bdc82 Code clean-up. Formatting. No functional change. ea7c2bdc82 is described below commit ea7c2bdc82e39c7558cb71a10f5e4aa043333842 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Jan 16 15:56:00 2025 +0000 Code clean-up. Formatting. No functional change. --- .../org/apache/tomcat/util/compat/Jre16Compat.java | 10 ++- .../org/apache/tomcat/util/compat/Jre19Compat.java | 8 +-- java/org/apache/tomcat/util/compat/Jre9Compat.java | 3 +- java/org/apache/tomcat/util/compat/JreCompat.java | 71 +++++++++------------- .../org/apache/tomcat/util/compat/JrePlatform.java | 13 ++-- java/org/apache/tomcat/util/compat/JreVendor.java | 8 +-- 6 files changed, 47 insertions(+), 66 deletions(-) diff --git a/java/org/apache/tomcat/util/compat/Jre16Compat.java b/java/org/apache/tomcat/util/compat/Jre16Compat.java index a0146388b5..e001acc540 100644 --- a/java/org/apache/tomcat/util/compat/Jre16Compat.java +++ b/java/org/apache/tomcat/util/compat/Jre16Compat.java @@ -70,8 +70,7 @@ class Jre16Compat extends Jre9Compat { public SocketAddress getUnixDomainSocketAddress(String path) { try { return (SocketAddress) unixDomainSocketAddressOfMethod.invoke(null, path); - } catch (IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new UnsupportedOperationException(e); } } @@ -80,8 +79,8 @@ class Jre16Compat extends Jre9Compat { @Override public ServerSocketChannel openUnixDomainServerSocketChannel() { try { - return (ServerSocketChannel) openServerSocketChannelFamilyMethod.invoke - (null, StandardProtocolFamily.valueOf("UNIX")); + return (ServerSocketChannel) openServerSocketChannelFamilyMethod.invoke(null, + StandardProtocolFamily.valueOf("UNIX")); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new UnsupportedOperationException(e); } @@ -91,8 +90,7 @@ class Jre16Compat extends Jre9Compat { @Override public SocketChannel openUnixDomainSocketChannel() { try { - return (SocketChannel) openSocketChannelFamilyMethod.invoke - (null, StandardProtocolFamily.valueOf("UNIX")); + return (SocketChannel) openSocketChannelFamilyMethod.invoke(null, StandardProtocolFamily.valueOf("UNIX")); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new UnsupportedOperationException(e); } diff --git a/java/org/apache/tomcat/util/compat/Jre19Compat.java b/java/org/apache/tomcat/util/compat/Jre19Compat.java index 45ce68b666..587ad39dcb 100644 --- a/java/org/apache/tomcat/util/compat/Jre19Compat.java +++ b/java/org/apache/tomcat/util/compat/Jre19Compat.java @@ -68,11 +68,9 @@ public class Jre19Compat extends Jre16Compat { return null; } - if (task!= null && task.getClass().getCanonicalName() != null && - (task.getClass().getCanonicalName().equals( - "org.apache.tomcat.util.threads.ThreadPoolExecutor.Worker") || - task.getClass().getCanonicalName().equals( - "java.util.concurrent.ThreadPoolExecutor.Worker"))) { + if (task != null && task.getClass().getCanonicalName() != null && (task.getClass().getCanonicalName() + .equals("org.apache.tomcat.util.threads.ThreadPoolExecutor.Worker") || + task.getClass().getCanonicalName().equals("java.util.concurrent.ThreadPoolExecutor.Worker"))) { Field executorField = task.getClass().getDeclaredField("this$0"); executorField.setAccessible(true); result = executorField.get(task); diff --git a/java/org/apache/tomcat/util/compat/Jre9Compat.java b/java/org/apache/tomcat/util/compat/Jre9Compat.java index 86fba5eb30..8324fe5748 100644 --- a/java/org/apache/tomcat/util/compat/Jre9Compat.java +++ b/java/org/apache/tomcat/util/compat/Jre9Compat.java @@ -203,8 +203,7 @@ class Jre9Compat extends JreCompat { @Override public JarFile jarFileNewInstance(File f) throws IOException { try { - return jarFileConstructor.newInstance( - f, Boolean.TRUE, Integer.valueOf(ZipFile.OPEN_READ), RUNTIME_VERSION); + return jarFileConstructor.newInstance(f, Boolean.TRUE, Integer.valueOf(ZipFile.OPEN_READ), RUNTIME_VERSION); } catch (ReflectiveOperationException | IllegalArgumentException e) { throw new IOException(e); } diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java b/java/org/apache/tomcat/util/compat/JreCompat.java index 9f177a738a..66b11684c7 100644 --- a/java/org/apache/tomcat/util/compat/JreCompat.java +++ b/java/org/apache/tomcat/util/compat/JreCompat.java @@ -40,9 +40,8 @@ import javax.security.auth.Subject; import org.apache.tomcat.util.res.StringManager; /** - * This is the base implementation class for JRE compatibility and provides an - * implementation based on Java 8. Sub-classes may extend this class and provide - * alternative implementations for later JRE versions + * This is the base implementation class for JRE compatibility and provides an implementation based on Java 8. + * Sub-classes may extend this class and provide alternative implementations for later JRE versions */ public class JreCompat { @@ -181,13 +180,11 @@ public class JreCompat { // Java 8 implementation of Java 9 methods /** - * Test if the provided exception is an instance of - * java.lang.reflect.InaccessibleObjectException. + * Test if the provided exception is an instance of java.lang.reflect.InaccessibleObjectException. * * @param t The exception to test * - * @return {@code true} if the exception is an instance of - * InaccessibleObjectException, otherwise {@code false} + * @return {@code true} if the exception is an instance of InaccessibleObjectException, otherwise {@code false} */ public boolean isInstanceOfInaccessibleObjectException(Throwable t) { // Exception does not exist prior to Java 9 @@ -199,8 +196,7 @@ public class JreCompat { * Set the application protocols the server will accept for ALPN * * @param sslParameters The SSL parameters for a connection - * @param protocols The application protocols to be allowed for that - * connection + * @param protocols The application protocols to be allowed for that connection */ public void setApplicationProtocols(SSLParameters sslParameters, String[] protocols) { if (setApplicationProtocolsMethod != null) { @@ -216,11 +212,9 @@ public class JreCompat { /** - * Get the application protocol that has been negotiated for connection - * associated with the given SSLEngine. + * Get the application protocol that has been negotiated for connection associated with the given SSLEngine. * - * @param sslEngine The SSLEngine for which to obtain the negotiated - * protocol + * @param sslEngine The SSLEngine for which to obtain the negotiated protocol * * @return The name of the negotiated protocol */ @@ -238,8 +232,8 @@ public class JreCompat { /** - * Disables caching for JAR URL connections. For Java 8 and earlier, this also disables - * caching for ALL URL connections. + * Disables caching for JAR URL connections. For Java 8 and earlier, this also disables caching for ALL URL + * connections. * * @throws IOException If a dummy JAR URLConnection can not be created */ @@ -253,11 +247,9 @@ public class JreCompat { /** - * Obtains the URLs for all the JARs on the module path when the JVM starts - * and adds them to the provided Deque. + * Obtains the URLs for all the JARs on the module path when the JVM starts and adds them to the provided Deque. * - * @param classPathUrlsToProcess The Deque to which the modules should be - * added + * @param classPathUrlsToProcess The Deque to which the modules should be added */ public void addBootModulePath(Deque<URL> classPathUrlsToProcess) { // NO-OP for Java 8. There is no module path. @@ -265,15 +257,14 @@ public class JreCompat { /** - * Creates a new JarFile instance. When running on Java 9 and later, the - * JarFile will be multi-release JAR aware. While this isn't strictly - * required to be in this package, it is provided as a convenience method. + * Creates a new JarFile instance. When running on Java 9 and later, the JarFile will be multi-release JAR aware. + * While this isn't strictly required to be in this package, it is provided as a convenience method. * * @param s The JAR file to open * * @return A JarFile instance based on the provided path * - * @throws IOException If an I/O error occurs creating the JarFile instance + * @throws IOException If an I/O error occurs creating the JarFile instance */ public final JarFile jarFileNewInstance(String s) throws IOException { return jarFileNewInstance(new File(s)); @@ -281,14 +272,13 @@ public class JreCompat { /** - * Creates a new JarFile instance. When running on Java 9 and later, the - * JarFile will be multi-release JAR aware. + * Creates a new JarFile instance. When running on Java 9 and later, the JarFile will be multi-release JAR aware. * * @param f The JAR file to open * * @return A JarFile instance based on the provided file * - * @throws IOException If an I/O error occurs creating the JarFile instance + * @throws IOException If an I/O error occurs creating the JarFile instance */ public JarFile jarFileNewInstance(File f) throws IOException { return new JarFile(f); @@ -298,10 +288,9 @@ public class JreCompat { /** * Is this JarFile a multi-release JAR file. * - * @param jarFile The JarFile to test + * @param jarFile The JarFile to test * - * @return {@code true} If it is a multi-release JAR file and is configured - * to behave as such. + * @return {@code true} If it is a multi-release JAR file and is configured to behave as such. */ public boolean jarFileIsMultiRelease(JarFile jarFile) { // Java 8 doesn't support multi-release so default to false @@ -315,14 +304,12 @@ public class JreCompat { /** - * Is the accessibleObject accessible (as a result of appropriate module - * exports) on the provided instance? + * Is the accessibleObject accessible (as a result of appropriate module exports) on the provided instance? * - * @param base The specific instance to be tested. - * @param accessibleObject The method/field/constructor to be tested. + * @param base The specific instance to be tested. + * @param accessibleObject The method/field/constructor to be tested. * - * @return {code true} if the AccessibleObject can be accessed otherwise - * {code false} + * @return {code true} if the AccessibleObject can be accessed otherwise {code false} */ public boolean canAccess(Object base, AccessibleObject accessibleObject) { // Java 8 doesn't support modules so default to true @@ -333,10 +320,9 @@ public class JreCompat { /** * Is the given class in an exported package? * - * @param type The class to test + * @param type The class to test * - * @return Always {@code true} for Java 8. {@code true} if the enclosing - * package is exported for Java 9+ + * @return Always {@code true} for Java 8. {@code true} if the enclosing package is exported for Java 9+ */ public boolean isExported(Class<?> type) { return true; @@ -346,10 +332,9 @@ public class JreCompat { /** * What is the module of the given class? * - * @param type The class to test + * @param type The class to test * - * @return Always {@code true} for Java 8. {@code true} if the enclosing - * package is exported for Java 9+ + * @return Always {@code true} for Java 8. {@code true} if the enclosing package is exported for Java 9+ */ public String getModuleName(Class<?> type) { return "NO_MODULE_JAVA_8"; @@ -360,7 +345,9 @@ public class JreCompat { /** * Return Unix domain socket address for given path. + * * @param path The path + * * @return the socket address */ public SocketAddress getUnixDomainSocketAddress(String path) { @@ -370,6 +357,7 @@ public class JreCompat { /** * Create server socket channel using the Unix domain socket ProtocolFamily. + * * @return the server socket channel */ public ServerSocketChannel openUnixDomainServerSocketChannel() { @@ -379,6 +367,7 @@ public class JreCompat { /** * Create socket channel using the Unix domain socket ProtocolFamily. + * * @return the socket channel */ public SocketChannel openUnixDomainSocketChannel() { diff --git a/java/org/apache/tomcat/util/compat/JrePlatform.java b/java/org/apache/tomcat/util/compat/JrePlatform.java index 66717d664f..089751d16f 100644 --- a/java/org/apache/tomcat/util/compat/JrePlatform.java +++ b/java/org/apache/tomcat/util/compat/JrePlatform.java @@ -26,12 +26,11 @@ public class JrePlatform { static { /* - * There are a few places where a) the behaviour of the Java API depends - * on the underlying platform and b) those behavioural differences have - * an impact on Tomcat. + * There are a few places where a) the behaviour of the Java API depends on the underlying platform and b) those + * behavioural differences have an impact on Tomcat. * - * Tomcat therefore needs to be able to determine the platform it is - * running on to account for those differences. + * Tomcat therefore needs to be able to determine the platform it is running on to account for those + * differences. * * In an ideal world this code would not exist. */ @@ -41,8 +40,8 @@ public class JrePlatform { if (System.getSecurityManager() == null) { osName = System.getProperty(OS_NAME_PROPERTY); } else { - osName = AccessController.doPrivileged( - (PrivilegedAction<String>) () -> System.getProperty(OS_NAME_PROPERTY)); + osName = AccessController + .doPrivileged((PrivilegedAction<String>) () -> System.getProperty(OS_NAME_PROPERTY)); } IS_MAC_OS = osName.toLowerCase(Locale.ENGLISH).startsWith("mac os x"); diff --git a/java/org/apache/tomcat/util/compat/JreVendor.java b/java/org/apache/tomcat/util/compat/JreVendor.java index caa0823ea8..2aea102bd6 100644 --- a/java/org/apache/tomcat/util/compat/JreVendor.java +++ b/java/org/apache/tomcat/util/compat/JreVendor.java @@ -22,11 +22,9 @@ public class JreVendor { static { /* - * There are a few places where Tomcat either accesses JVM internals - * (e.g. the memory leak protection) or where feature support varies - * between JVMs (e.g. SPNEGO). These flags exist to enable Tomcat to - * adjust its behaviour based on the vendor of the JVM. In an ideal - * world this code would not exist. + * There are a few places where Tomcat either accesses JVM internals (e.g. the memory leak protection) or where + * feature support varies between JVMs (e.g. SPNEGO). These flags exist to enable Tomcat to adjust its behaviour + * based on the vendor of the JVM. In an ideal world this code would not exist. */ String vendor = System.getProperty("java.vendor", ""); vendor = vendor.toLowerCase(Locale.ENGLISH); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org