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 2b0508581a Code clean-up - formatting. No functional change. 2b0508581a is described below commit 2b0508581aaa6413a83dc1a334b3cc8a17661bca Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri May 17 19:35:25 2024 +0100 Code clean-up - formatting. No functional change. --- java/org/apache/catalina/util/CharsetMapper.java | 37 ++-- .../apache/catalina/util/ConcurrentDateFormat.java | 11 +- java/org/apache/catalina/util/ContextName.java | 32 ++- .../catalina/util/CustomObjectInputStream.java | 59 +++--- java/org/apache/catalina/util/DOMWriter.java | 5 +- .../org/apache/catalina/util/ErrorPageSupport.java | 10 +- java/org/apache/catalina/util/Extension.java | 72 +++---- .../apache/catalina/util/ExtensionValidator.java | 147 +++++-------- java/org/apache/catalina/util/IOTools.java | 36 ++-- java/org/apache/catalina/util/Introspection.java | 66 +++--- java/org/apache/catalina/util/LifecycleBase.java | 85 +++----- .../apache/catalina/util/LifecycleMBeanBase.java | 65 +++--- .../org/apache/catalina/util/ManifestResource.java | 67 +++--- java/org/apache/catalina/util/ParameterMap.java | 33 ++- java/org/apache/catalina/util/RequestUtil.java | 9 +- java/org/apache/catalina/util/ResourceSet.java | 31 +-- java/org/apache/catalina/util/ServerInfo.java | 21 +- java/org/apache/catalina/util/SessionConfig.java | 14 +- .../catalina/util/SessionIdGeneratorBase.java | 97 ++++----- .../catalina/util/StandardSessionIdGenerator.java | 4 +- java/org/apache/catalina/util/Strftime.java | 232 ++++++++++----------- java/org/apache/catalina/util/StringUtil.java | 10 +- java/org/apache/catalina/util/TLSUtil.java | 10 +- .../apache/catalina/util/TimeBucketCounter.java | 8 +- java/org/apache/catalina/util/ToStringUtil.java | 6 +- java/org/apache/catalina/util/TomcatCSS.java | 13 +- java/org/apache/catalina/util/URLEncoder.java | 30 ++- java/org/apache/catalina/util/XMLWriter.java | 122 ++++++----- 28 files changed, 568 insertions(+), 764 deletions(-) diff --git a/java/org/apache/catalina/util/CharsetMapper.java b/java/org/apache/catalina/util/CharsetMapper.java index c04d1c5e4e..5bb215e62f 100644 --- a/java/org/apache/catalina/util/CharsetMapper.java +++ b/java/org/apache/catalina/util/CharsetMapper.java @@ -25,14 +25,11 @@ import org.apache.tomcat.util.ExceptionUtils; import org.apache.tomcat.util.compat.JreCompat; - /** - * Utility class that attempts to map from a Locale to the corresponding - * character set to be used for interpreting input text (or generating - * output text) when the Content-Type header does not include one. You - * can customize the behavior of this class by modifying the mapping data - * it loads, or by subclassing it (to change the algorithm) and then using - * your own version for a particular web application. + * Utility class that attempts to map from a Locale to the corresponding character set to be used for interpreting input + * text (or generating output text) when the Content-Type header does not include one. You can customize the behavior of + * this class by modifying the mapping data it loads, or by subclassing it (to change the algorithm) and then using your + * own version for a particular web application. * * @author Craig R. McClanahan */ @@ -45,8 +42,7 @@ public class CharsetMapper { /** * Default properties resource name. */ - public static final String DEFAULT_RESOURCE = - "/org/apache/catalina/util/CharsetMapperDefault.properties"; + public static final String DEFAULT_RESOURCE = "/org/apache/catalina/util/CharsetMapperDefault.properties"; // ---------------------------------------------------------- Constructors @@ -65,8 +61,7 @@ public class CharsetMapper { * * @param name Name of a properties resource to be loaded * - * @exception IllegalArgumentException if the specified properties - * resource could not be loaded for any reason. + * @exception IllegalArgumentException if the specified properties resource could not be loaded for any reason. */ public CharsetMapper(String name) { if (JreCompat.isGraalAvailable()) { @@ -86,8 +81,7 @@ public class CharsetMapper { /** - * The mapping properties that have been initialized from the specified or - * default properties resource. + * The mapping properties that have been initialized from the specified or default properties resource. */ private Properties map = new Properties(); @@ -96,11 +90,11 @@ public class CharsetMapper { /** - * Calculate the name of a character set to be assumed, given the specified - * Locale and the absence of a character set specified as part of the - * content type header. + * Calculate the name of a character set to be assumed, given the specified Locale and the absence of a character + * set specified as part of the content type header. * * @param locale The locale for which to calculate a character set + * * @return the charset name */ public String getCharset(Locale locale) { @@ -108,8 +102,7 @@ public class CharsetMapper { // then language only String charset = map.getProperty(locale.toString()); if (charset == null) { - charset = map.getProperty(locale.getLanguage() + "_" - + locale.getCountry()); + charset = map.getProperty(locale.getLanguage() + "_" + locale.getCountry()); if (charset == null) { charset = map.getProperty(locale.getLanguage()); } @@ -119,12 +112,10 @@ public class CharsetMapper { /** - * The deployment descriptor can have a - * locale-encoding-mapping-list element which describes the - * webapp's desired mapping from locale to charset. This method - * gets called when processing the web.xml file for a context + * The deployment descriptor can have a locale-encoding-mapping-list element which describes the webapp's desired + * mapping from locale to charset. This method gets called when processing the web.xml file for a context * - * @param locale The locale for a character set + * @param locale The locale for a character set * @param charset The charset to be associated with the locale */ public void addCharsetMappingFromDeploymentDescriptor(String locale, String charset) { diff --git a/java/org/apache/catalina/util/ConcurrentDateFormat.java b/java/org/apache/catalina/util/ConcurrentDateFormat.java index 7408938fa6..76dd668f26 100644 --- a/java/org/apache/catalina/util/ConcurrentDateFormat.java +++ b/java/org/apache/catalina/util/ConcurrentDateFormat.java @@ -24,12 +24,10 @@ import java.util.TimeZone; import java.util.concurrent.ConcurrentLinkedQueue; /** - * A thread safe wrapper around {@link SimpleDateFormat} that does not make use - * of ThreadLocal and - broadly - only creates enough SimpleDateFormat objects - * to satisfy the concurrency requirements. + * A thread safe wrapper around {@link SimpleDateFormat} that does not make use of ThreadLocal and - broadly - only + * creates enough SimpleDateFormat objects to satisfy the concurrency requirements. * - * @deprecated Unused. This will be removed in Tomcat 10. - * Use {@link org.apache.tomcat.util.http.ConcurrentDateFormat} + * @deprecated Unused. This will be removed in Tomcat 10. Use {@link org.apache.tomcat.util.http.ConcurrentDateFormat} */ @Deprecated public class ConcurrentDateFormat { @@ -52,8 +50,7 @@ public class ConcurrentDateFormat { return FORMAT_RFC1123.format(date); } - public ConcurrentDateFormat(String format, Locale locale, - TimeZone timezone) { + public ConcurrentDateFormat(String format, Locale locale, TimeZone timezone) { this.format = format; this.locale = locale; this.timezone = timezone; diff --git a/java/org/apache/catalina/util/ContextName.java b/java/org/apache/catalina/util/ContextName.java index f426d41972..14588a9bfd 100644 --- a/java/org/apache/catalina/util/ContextName.java +++ b/java/org/apache/catalina/util/ContextName.java @@ -19,8 +19,8 @@ package org.apache.catalina.util; import java.util.Locale; /** - * Utility class to manage context names so there is one place where the - * conversions between baseName, path and version take place. + * Utility class to manage context names so there is one place where the conversions between baseName, path and version + * take place. */ public final class ContextName { public static final String ROOT_NAME = "ROOT"; @@ -34,13 +34,11 @@ public final class ContextName { /** - * Creates an instance from a context name, display name, base name, - * directory name, WAR name or context.xml name. + * Creates an instance from a context name, display name, base name, directory name, WAR name or context.xml name. * - * @param name The name to use as the basis for this object - * @param stripFileExtension If a .war or .xml file extension is present - * at the end of the provided name should it be - * removed? + * @param name The name to use as the basis for this object + * @param stripFileExtension If a .war or .xml file extension is present at the end of the provided name should it + * be removed? */ public ContextName(String name, boolean stripFileExtension) { @@ -62,10 +60,9 @@ public final class ContextName { } // Remove any file extensions - if (stripFileExtension && - (tmp1.toLowerCase(Locale.ENGLISH).endsWith(".war") || - tmp1.toLowerCase(Locale.ENGLISH).endsWith(".xml"))) { - tmp1 = tmp1.substring(0, tmp1.length() -4); + if (stripFileExtension && (tmp1.toLowerCase(Locale.ENGLISH).endsWith(".war") || + tmp1.toLowerCase(Locale.ENGLISH).endsWith(".xml"))) { + tmp1 = tmp1.substring(0, tmp1.length() - 4); } baseName = tmp1; @@ -97,8 +94,8 @@ public final class ContextName { /** * Construct an instance from a path and version. * - * @param path Context path to use - * @param version Context version to use + * @param path Context path to use + * @param version Context version to use */ public ContextName(String path, String version) { // Path should never be null, '/' or '/ROOT' @@ -127,8 +124,7 @@ public final class ContextName { if (this.path.isEmpty()) { tmp.append(ROOT_NAME); } else { - tmp.append(this.path.substring(1).replace('/', - FWD_SLASH_REPLACEMENT)); + tmp.append(this.path.substring(1).replace('/', FWD_SLASH_REPLACEMENT)); } if (!this.version.isEmpty()) { tmp.append(VERSION_MARKER); @@ -176,8 +172,8 @@ public final class ContextName { /** - * Extract the final component of the given path which is assumed to be a - * base name and generate a {@link ContextName} from that base name. + * Extract the final component of the given path which is assumed to be a base name and generate a + * {@link ContextName} from that base name. * * @param path The path that ends in a base name * diff --git a/java/org/apache/catalina/util/CustomObjectInputStream.java b/java/org/apache/catalina/util/CustomObjectInputStream.java index 4d5e88fe76..f5cdf104f8 100644 --- a/java/org/apache/catalina/util/CustomObjectInputStream.java +++ b/java/org/apache/catalina/util/CustomObjectInputStream.java @@ -31,9 +31,8 @@ import org.apache.juli.logging.Log; import org.apache.tomcat.util.res.StringManager; /** - * Custom subclass of <code>ObjectInputStream</code> that loads from the - * class loader for this web application. This allows classes defined only - * with the web application to be found correctly. + * Custom subclass of <code>ObjectInputStream</code> that loads from the class loader for this web application. This + * allows classes defined only with the web application to be found correctly. * * @author Craig R. McClanahan * @author Bip Thelin @@ -42,8 +41,7 @@ public final class CustomObjectInputStream extends ObjectInputStream { private static final StringManager sm = StringManager.getManager(CustomObjectInputStream.class); - private static final WeakHashMap<ClassLoader, Set<String>> reportedClassCache = - new WeakHashMap<>(); + private static final WeakHashMap<ClassLoader,Set<String>> reportedClassCache = new WeakHashMap<>(); /** * The class loader we will use to resolve classes. @@ -58,10 +56,9 @@ public final class CustomObjectInputStream extends ObjectInputStream { /** - * Construct a new instance of CustomObjectInputStream without any filtering - * of deserialized classes. + * Construct a new instance of CustomObjectInputStream without any filtering of deserialized classes. * - * @param stream The input stream we will read from + * @param stream The input stream we will read from * @param classLoader The class loader used to instantiate objects * * @exception IOException if an input/output error occurs @@ -72,29 +69,24 @@ public final class CustomObjectInputStream extends ObjectInputStream { /** - * Construct a new instance of CustomObjectInputStream with filtering of - * deserialized classes. + * Construct a new instance of CustomObjectInputStream with filtering of deserialized classes. * - * @param stream The input stream we will read from - * @param classLoader The class loader used to instantiate objects - * @param log The logger to use to report any issues. It may only be null if - * the filterMode does not require logging - * @param allowedClassNamePattern The regular expression to use to filter - * deserialized classes. The fully qualified - * class name must match this pattern for - * deserialization to be allowed if filtering - * is enabled. - * @param warnOnFailure Should any failures be logged? + * @param stream The input stream we will read from + * @param classLoader The class loader used to instantiate objects + * @param log The logger to use to report any issues. It may only be null if the filterMode does + * not require logging + * @param allowedClassNamePattern The regular expression to use to filter deserialized classes. The fully qualified + * class name must match this pattern for deserialization to be allowed if + * filtering is enabled. + * @param warnOnFailure Should any failures be logged? * * @exception IOException if an input/output error occurs */ - public CustomObjectInputStream(InputStream stream, ClassLoader classLoader, - Log log, Pattern allowedClassNamePattern, boolean warnOnFailure) - throws IOException { + public CustomObjectInputStream(InputStream stream, ClassLoader classLoader, Log log, + Pattern allowedClassNamePattern, boolean warnOnFailure) throws IOException { super(stream); if (log == null && allowedClassNamePattern != null && warnOnFailure) { - throw new IllegalArgumentException( - sm.getString("customObjectInputStream.logRequired")); + throw new IllegalArgumentException(sm.getString("customObjectInputStream.logRequired")); } this.classLoader = classLoader; this.log = log; @@ -127,17 +119,16 @@ public final class CustomObjectInputStream extends ObjectInputStream { /** - * Load the local class equivalent of the specified stream class - * description, by using the class loader assigned to this Context. + * Load the local class equivalent of the specified stream class description, by using the class loader assigned to + * this Context. * * @param classDesc Class description from the input stream * * @exception ClassNotFoundException if this class cannot be found - * @exception IOException if an input/output error occurs + * @exception IOException if an input/output error occurs */ @Override - public Class<?> resolveClass(ObjectStreamClass classDesc) - throws ClassNotFoundException, IOException { + public Class<?> resolveClass(ObjectStreamClass classDesc) throws ClassNotFoundException, IOException { String name = classDesc.getName(); if (allowedClassNamePattern != null) { @@ -170,13 +161,11 @@ public final class CustomObjectInputStream extends ObjectInputStream { /** - * Return a proxy class that implements the interfaces named in a proxy - * class descriptor. Do this using the class loader assigned to this - * Context. + * Return a proxy class that implements the interfaces named in a proxy class descriptor. Do this using the class + * loader assigned to this Context. */ @Override - protected Class<?> resolveProxyClass(String[] interfaces) - throws IOException, ClassNotFoundException { + protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { Class<?>[] cinterfaces = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { diff --git a/java/org/apache/catalina/util/DOMWriter.java b/java/org/apache/catalina/util/DOMWriter.java index 96f6567764..0cd3532526 100644 --- a/java/org/apache/catalina/util/DOMWriter.java +++ b/java/org/apache/catalina/util/DOMWriter.java @@ -41,6 +41,7 @@ public class DOMWriter { /** * Prints the specified node, recursively. + * * @param node The node to output */ public void print(Node node) { @@ -102,7 +103,7 @@ public class DOMWriter { } out.print("?>"); break; - } + } if (type == Node.ELEMENT_NODE) { out.print("</"); @@ -128,7 +129,9 @@ public class DOMWriter { /** * Returns a sorted list of attributes. + * * @param attrs The map to sort + * * @return a sorted attribute array */ private Attr[] sortAttributes(NamedNodeMap attrs) { diff --git a/java/org/apache/catalina/util/ErrorPageSupport.java b/java/org/apache/catalina/util/ErrorPageSupport.java index 93012befdf..d87c21fe7a 100644 --- a/java/org/apache/catalina/util/ErrorPageSupport.java +++ b/java/org/apache/catalina/util/ErrorPageSupport.java @@ -24,16 +24,15 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.tomcat.util.descriptor.web.ErrorPage; /** - * Provides support for tracking per exception type and per HTTP status code - * error pages. + * Provides support for tracking per exception type and per HTTP status code error pages. */ public class ErrorPageSupport { // Fully qualified class name to error page - private Map<String, ErrorPage> exceptionPages = new ConcurrentHashMap<>(); + private Map<String,ErrorPage> exceptionPages = new ConcurrentHashMap<>(); // HTTP status code to error page - private Map<Integer, ErrorPage> statusPages = new ConcurrentHashMap<>(); + private Map<Integer,ErrorPage> statusPages = new ConcurrentHashMap<>(); public void add(ErrorPage errorPage) { @@ -66,8 +65,7 @@ public class ErrorPageSupport { * * @param exceptionType The fully qualified class name of the exception type * - * @return The ErrorPage for the named exception type, or {@code null} if - * none is configured + * @return The ErrorPage for the named exception type, or {@code null} if none is configured */ public ErrorPage find(String exceptionType) { return exceptionPages.get(exceptionType); diff --git a/java/org/apache/catalina/util/Extension.java b/java/org/apache/catalina/util/Extension.java index ccc77f1e7c..1cbd87d212 100644 --- a/java/org/apache/catalina/util/Extension.java +++ b/java/org/apache/catalina/util/Extension.java @@ -21,20 +21,15 @@ import java.util.StringTokenizer; /** - * Utility class that represents either an available "Optional Package" - * (formerly known as "Standard Extension") as described in the manifest - * of a JAR file, or the requirement for such an optional package. It is - * used to support the requirements of the Servlet Specification, version - * 2.3, related to providing shared extensions to all webapps. + * Utility class that represents either an available "Optional Package" (formerly known as "Standard Extension") as + * described in the manifest of a JAR file, or the requirement for such an optional package. It is used to support the + * requirements of the Servlet Specification, version 2.3, related to providing shared extensions to all webapps. * <p> - * In addition, static utility methods are available to scan a manifest - * and return an array of either available or required optional modules - * documented in that manifest. + * In addition, static utility methods are available to scan a manifest and return an array of either available or + * required optional modules documented in that manifest. * <p> - * For more information about optional packages, see the document - * <em>Optional Package Versioning</em> in the documentation bundle for your - * Java2 Standard Edition package, in file - * <code>guide/extensions/versioning.html</code>. + * For more information about optional packages, see the document <em>Optional Package Versioning</em> in the + * documentation bundle for your Java2 Standard Edition package, in file <code>guide/extensions/versioning.html</code>. * * @author Craig McClanahan * @author Justyna Horwat @@ -61,8 +56,8 @@ public final class Extension { } /** - * The URL from which the most recent version of this optional package - * can be obtained if it is not already installed. + * The URL from which the most recent version of this optional package can be obtained if it is not already + * installed. */ private String implementationURL = null; @@ -76,8 +71,7 @@ public final class Extension { /** - * The name of the company or organization that produced this - * implementation of this optional package. + * The name of the company or organization that produced this implementation of this optional package. */ private String implementationVendor = null; @@ -91,8 +85,7 @@ public final class Extension { /** - * The unique identifier of the company that produced the optional - * package contained in this JAR file. + * The unique identifier of the company that produced the optional package contained in this JAR file. */ private String implementationVendorId = null; @@ -106,8 +99,7 @@ public final class Extension { /** - * The version number (dotted decimal notation) for this implementation - * of the optional package. + * The version number (dotted decimal notation) for this implementation of the optional package. */ private String implementationVersion = null; @@ -121,8 +113,8 @@ public final class Extension { /** - * The name of the company or organization that originated the - * specification to which this optional package conforms. + * The name of the company or organization that originated the specification to which this optional package + * conforms. */ private String specificationVendor = null; @@ -136,8 +128,7 @@ public final class Extension { /** - * The version number (dotted decimal notation) of the specification - * to which this optional package conforms. + * The version number (dotted decimal notation) of the specification to which this optional package conforms. */ private String specificationVersion = null; @@ -151,8 +142,7 @@ public final class Extension { /** - * fulfilled is true if all the required extension dependencies have been - * satisfied + * fulfilled is true if all the required extension dependencies have been satisfied */ private boolean fulfilled = false; @@ -167,13 +157,12 @@ public final class Extension { // --------------------------------------------------------- Public Methods /** - * Return <code>true</code> if the specified <code>Extension</code> - * (which represents an optional package required by this application) - * is satisfied by this <code>Extension</code> (which represents an - * optional package that is already installed. Otherwise, return - * <code>false</code>. + * Return <code>true</code> if the specified <code>Extension</code> (which represents an optional package required + * by this application) is satisfied by this <code>Extension</code> (which represents an optional package that is + * already installed. Otherwise, return <code>false</code>. * * @param required Extension of the required optional package + * * @return <code>true</code> if the extension is satisfied */ public boolean isCompatibleWith(Extension required) { @@ -188,8 +177,7 @@ public final class Extension { // If specified, available specification version must be >= required if (required.getSpecificationVersion() != null) { - if (!isNewer(specificationVersion, - required.getSpecificationVersion())) { + if (!isNewer(specificationVersion, required.getSpecificationVersion())) { return false; } } @@ -199,16 +187,14 @@ public final class Extension { if (implementationVendorId == null) { return false; } - if (!implementationVendorId.equals(required - .getImplementationVendorId())) { + if (!implementationVendorId.equals(required.getImplementationVendorId())) { return false; } } // If specified, Implementation version must be >= required if (required.getImplementationVersion() != null) { - if (!isNewer(implementationVersion, - required.getImplementationVersion())) { + if (!isNewer(implementationVersion, required.getImplementationVersion())) { return false; } } @@ -254,18 +240,16 @@ public final class Extension { // -------------------------------------------------------- Private Methods - /** - * Return <code>true</code> if the first version number is greater than - * or equal to the second; otherwise return <code>false</code>. + * Return <code>true</code> if the first version number is greater than or equal to the second; otherwise return + * <code>false</code>. * - * @param first First version number (dotted decimal) + * @param first First version number (dotted decimal) * @param second Second version number (dotted decimal) * * @exception NumberFormatException on a malformed version number */ - private boolean isNewer(String first, String second) - throws NumberFormatException { + private boolean isNewer(String first, String second) throws NumberFormatException { if ((first == null) || (second == null)) { return false; @@ -302,7 +286,7 @@ public final class Extension { } } - return true; // Exact match + return true; // Exact match } diff --git a/java/org/apache/catalina/util/ExtensionValidator.java b/java/org/apache/catalina/util/ExtensionValidator.java index ca9a28ab55..378abcafad 100644 --- a/java/org/apache/catalina/util/ExtensionValidator.java +++ b/java/org/apache/catalina/util/ExtensionValidator.java @@ -36,12 +36,10 @@ import org.apache.tomcat.util.res.StringManager; /** - * Ensures that all extension dependencies are resolved for a WEB application - * are met. This class builds a list of extensions available to an application - * and then validates those extensions. - * - * See http://docs.oracle.com/javase/1.4.2/docs/guide/extensions/spec.html - * for a detailed explanation of the extension mechanism in Java. + * Ensures that all extension dependencies are resolved for a WEB application are met. This class builds a list of + * extensions available to an application and then validates those extensions. See + * http://docs.oracle.com/javase/1.4.2/docs/guide/extensions/spec.html for a detailed explanation of the extension + * mechanism in Java. * * @author Greg Murray * @author Justyna Horwat @@ -53,32 +51,27 @@ public final class ExtensionValidator { /** * The string resources for this package. */ - private static final StringManager sm = - StringManager.getManager("org.apache.catalina.util"); + private static final StringManager sm = StringManager.getManager("org.apache.catalina.util"); private static volatile List<Extension> containerAvailableExtensions = null; - private static final List<ManifestResource> containerManifestResources = - new ArrayList<>(); + private static final List<ManifestResource> containerManifestResources = new ArrayList<>(); // ----------------------------------------------------- Static Initializer /* - * This static initializer loads the container level extensions that are - * available to all web applications. This method scans all extension - * directories available via the "java.ext.dirs" System property. + * This static initializer loads the container level extensions that are available to all web applications. This + * method scans all extension directories available via the "java.ext.dirs" System property. * - * The System Class-Path is also scanned for jar files that may contain - * available extensions. + * The System Class-Path is also scanned for jar files that may contain available extensions. */ static { // check for container level optional packages String systemClasspath = System.getProperty("java.class.path"); - StringTokenizer strTok = new StringTokenizer(systemClasspath, - File.pathSeparator); + StringTokenizer strTok = new StringTokenizer(systemClasspath, File.pathSeparator); // build a list of jar files in the classpath while (strTok.hasMoreTokens()) { @@ -89,8 +82,7 @@ public final class ExtensionValidator { try { addSystemResource(item); } catch (IOException e) { - log.error(sm.getString - ("extensionValidator.failload", item), e); + log.error(sm.getString("extensionValidator.failload", item), e); } } } @@ -105,27 +97,21 @@ public final class ExtensionValidator { /** - * Runtime validation of a Web Application. - * - * This method uses JNDI to look up the resources located under a - * <code>DirContext</code>. It locates Web Application MANIFEST.MF - * file in the /META-INF/ directory of the application and all - * MANIFEST.MF files in each JAR file located in the WEB-INF/lib - * directory and creates an <code>ArrayList</code> of - * <code>ManifestResource</code> objects. These objects are then passed - * to the validateManifestResources method for validation. + * Runtime validation of a Web Application. This method uses JNDI to look up the resources located under a + * <code>DirContext</code>. It locates Web Application MANIFEST.MF file in the /META-INF/ directory of the + * application and all MANIFEST.MF files in each JAR file located in the WEB-INF/lib directory and creates an + * <code>ArrayList</code> of <code>ManifestResource</code> objects. These objects are then passed to the + * validateManifestResources method for validation. * * @param resources The resources configured for this Web Application - * @param context The context from which the Logger and path to the - * application + * @param context The context from which the Logger and path to the application * * @return true if all required extensions satisfied + * * @throws IOException Error reading resources needed for validation */ - public static synchronized boolean validateApplication( - WebResourceRoot resources, - Context context) - throws IOException { + public static synchronized boolean validateApplication(WebResourceRoot resources, Context context) + throws IOException { String appName = context.getName(); List<ManifestResource> appManifestResources = new ArrayList<>(); @@ -135,24 +121,21 @@ public final class ExtensionValidator { if (resource.isFile()) { try (InputStream inputStream = resource.getInputStream()) { Manifest manifest = new Manifest(inputStream); - ManifestResource mre = new ManifestResource - (sm.getString("extensionValidator.web-application-manifest"), - manifest, ManifestResource.WAR); + ManifestResource mre = new ManifestResource(sm.getString("extensionValidator.web-application-manifest"), + manifest, ManifestResource.WAR); appManifestResources.add(mre); } } // Web application library manifests - WebResource[] manifestResources = - resources.getClassLoaderResources("/META-INF/MANIFEST.MF"); + WebResource[] manifestResources = resources.getClassLoaderResources("/META-INF/MANIFEST.MF"); for (WebResource manifestResource : manifestResources) { if (manifestResource.isFile()) { // Primarily used for error reporting String jarName = manifestResource.getURL().toExternalForm(); Manifest jmanifest = manifestResource.getManifest(); if (jmanifest != null) { - ManifestResource mre = new ManifestResource(jarName, - jmanifest, ManifestResource.APPLICATION); + ManifestResource mre = new ManifestResource(jarName, jmanifest, ManifestResource.APPLICATION); appManifestResources.add(mre); } } @@ -163,18 +146,19 @@ public final class ExtensionValidator { /** - * Checks to see if the given system JAR file contains a MANIFEST, and adds - * it to the container's manifest resources. + * Checks to see if the given system JAR file contains a MANIFEST, and adds it to the container's manifest + * resources. * * @param jarFile The system JAR whose manifest to add + * * @throws IOException Error reading JAR file */ public static void addSystemResource(File jarFile) throws IOException { try (InputStream is = new FileInputStream(jarFile)) { Manifest manifest = getManifest(is); if (manifest != null) { - ManifestResource mre = new ManifestResource(jarFile.getAbsolutePath(), manifest, - ManifestResource.SYSTEM); + ManifestResource mre = + new ManifestResource(jarFile.getAbsolutePath(), manifest, ManifestResource.SYSTEM); containerManifestResources.add(mre); } } @@ -185,26 +169,17 @@ public final class ExtensionValidator { /** - * Validates an <code>ArrayList</code> of <code>ManifestResource</code> - * objects. This method requires an application name (which is the - * context root of the application at runtime). + * Validates an <code>ArrayList</code> of <code>ManifestResource</code> objects. This method requires an application + * name (which is the context root of the application at runtime). <code>false</code> is returned if the extension + * dependencies represented by any given <code>ManifestResource</code> objects is not met. This method should also + * provide static validation of a Web Application if provided with the necessary parameters. * - * <code>false</code> is returned if the extension dependencies - * represented by any given <code>ManifestResource</code> objects - * is not met. - * - * This method should also provide static validation of a Web Application - * if provided with the necessary parameters. - * - * @param appName The name of the Application that will appear in the - * error messages - * @param resources A list of <code>ManifestResource</code> objects - * to be validated. + * @param appName The name of the Application that will appear in the error messages + * @param resources A list of <code>ManifestResource</code> objects to be validated. * * @return true if manifest resource file requirements are met */ - private static boolean validateManifestResources(String appName, - List<ManifestResource> resources) { + private static boolean validateManifestResources(String appName, List<ManifestResource> resources) { boolean passes = true; int failureCount = 0; List<Extension> availableExtensions = null; @@ -223,8 +198,7 @@ public final class ExtensionValidator { // load the container level resource map if it has not been built // yet if (containerAvailableExtensions == null) { - containerAvailableExtensions - = buildAvailableExtensionsList(containerManifestResources); + containerAvailableExtensions = buildAvailableExtensionsList(containerManifestResources); } // iterate through the list of required extensions @@ -252,10 +226,8 @@ public final class ExtensionValidator { } if (!found) { // Failure - log.info(sm.getString( - "extensionValidator.extension-not-found-error", - appName, mre.getResourceName(), - requiredExt.getExtensionName())); + log.info(sm.getString("extensionValidator.extension-not-found-error", appName, + mre.getResourceName(), requiredExt.getExtensionName())); passes = false; failureCount++; } @@ -263,33 +235,26 @@ public final class ExtensionValidator { } if (!passes) { - log.info(sm.getString( - "extensionValidator.extension-validation-error", appName, - failureCount + "")); + log.info(sm.getString("extensionValidator.extension-validation-error", appName, failureCount + "")); } return passes; } - /* - * Build this list of available extensions so that we do not have to - * re-build this list every time we iterate through the list of required - * extensions. All available extensions in all of the - * <code>ManifestResource</code> objects will be added to a - * <code>HashMap</code> which is returned on the first dependency list - * processing pass. - * - * The key is the name + implementation version. - * - * NOTE: A list is built only if there is a dependency that needs - * to be checked (performance optimization). - * - * @param resources A list of <code>ManifestResource</code> objects - * - * @return HashMap Map of available extensions - */ - private static List<Extension> buildAvailableExtensionsList( - List<ManifestResource> resources) { + /* + * Build this list of available extensions so that we do not have to re-build this list every time we iterate + * through the list of required extensions. All available extensions in all of the <code>ManifestResource</code> + * objects will be added to a <code>HashMap</code> which is returned on the first dependency list processing pass. + * + * The key is the name + implementation version. + * + * NOTE: A list is built only if there is a dependency that needs to be checked (performance optimization). + * + * @param resources A list of <code>ManifestResource</code> objects + * + * @return HashMap Map of available extensions + */ + private static List<Extension> buildAvailableExtensionsList(List<ManifestResource> resources) { List<Extension> availableList = null; @@ -314,6 +279,7 @@ public final class ExtensionValidator { * Return the Manifest from a jar file or war file * * @param inStream Input stream to a WAR or JAR file + * * @return The WAR's or JAR's manifest */ private static Manifest getManifest(InputStream inStream) throws IOException { @@ -333,8 +299,7 @@ public final class ExtensionValidator { // get the files in the extensions directory String extensionsDir = System.getProperty(property); if (extensionsDir != null) { - StringTokenizer extensionsTok - = new StringTokenizer(extensionsDir, File.pathSeparator); + StringTokenizer extensionsTok = new StringTokenizer(extensionsDir, File.pathSeparator); while (extensionsTok.hasMoreTokens()) { File targetDir = new File(extensionsTok.nextToken()); if (!targetDir.isDirectory()) { diff --git a/java/org/apache/catalina/util/IOTools.java b/java/org/apache/catalina/util/IOTools.java index 7b5507dfbd..a9835bb29c 100644 --- a/java/org/apache/catalina/util/IOTools.java +++ b/java/org/apache/catalina/util/IOTools.java @@ -29,49 +29,47 @@ import java.io.Writer; * @author Dan Sandberg */ public class IOTools { - protected static final int DEFAULT_BUFFER_SIZE=4*1024; //4k + protected static final int DEFAULT_BUFFER_SIZE = 4 * 1024; // 4k private IOTools() { - //Ensure non-instantiability + // Ensure non-instantiability } /** - * Read input from reader and write it to writer until there is no more - * input from reader. + * Read input from reader and write it to writer until there is no more input from reader. * * @param reader the reader to read from. * @param writer the writer to write to. - * @param buf the char array to use as a buffer + * @param buf the char array to use as a buffer + * * @throws IOException IO error */ - public static void flow( Reader reader, Writer writer, char[] buf ) - throws IOException { + public static void flow(Reader reader, Writer writer, char[] buf) throws IOException { int numRead; - while ( (numRead = reader.read(buf) ) >= 0) { + while ((numRead = reader.read(buf)) >= 0) { writer.write(buf, 0, numRead); } } /** - * Read input from reader and write it to writer until there is no more - * input from reader. + * Read input from reader and write it to writer until there is no more input from reader. * * @param reader the reader to read from. * @param writer the writer to write to. + * * @throws IOException IO error + * * @see #flow( Reader, Writer, char[] ) */ - public static void flow( Reader reader, Writer writer ) - throws IOException { + public static void flow(Reader reader, Writer writer) throws IOException { char[] buf = new char[DEFAULT_BUFFER_SIZE]; - flow( reader, writer, buf ); + flow(reader, writer, buf); } /** - * Read input from input stream and write it to output stream until there is - * no more input from input stream using a new buffer of the default size - * (4 KiB). + * Read input from input stream and write it to output stream until there is no more input from input stream using a + * new buffer of the default size (4 KiB). * * @param is input stream the input stream to read from. * @param os output stream the output stream to write to. @@ -81,7 +79,7 @@ public class IOTools { public static void flow(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[DEFAULT_BUFFER_SIZE]; int numRead; - while ( (numRead = is.read(buf) ) >= 0) { + while ((numRead = is.read(buf)) >= 0) { if (os != null) { os.write(buf, 0, numRead); } @@ -92,8 +90,8 @@ public class IOTools { /** * Read until EOF or the buffer is filled. * - * @param is The source to read from - * @param buf The buffer to write to + * @param is The source to read from + * @param buf The buffer to write to * * @return The number of bytes read * diff --git a/java/org/apache/catalina/util/Introspection.java b/java/org/apache/catalina/util/Introspection.java index 5c9bc2bcfd..b67b6da52b 100644 --- a/java/org/apache/catalina/util/Introspection.java +++ b/java/org/apache/catalina/util/Introspection.java @@ -30,21 +30,20 @@ import org.apache.tomcat.util.ExceptionUtils; import org.apache.tomcat.util.res.StringManager; /** - * Provides introspection utilities that either require knowledge of Tomcat - * internals or are solely used by Tomcat internals. + * Provides introspection utilities that either require knowledge of Tomcat internals or are solely used by Tomcat + * internals. */ public class Introspection { - private static final StringManager sm = - StringManager.getManager("org.apache.catalina.util"); + private static final StringManager sm = StringManager.getManager("org.apache.catalina.util"); /** - * Extract the Java Bean property name from the setter name. + * Extract the Java Bean property name from the setter name. Note: This method assumes that the method name has + * already been checked for correctness. * - * Note: This method assumes that the method name has already been checked - * for correctness. * @param setter The setter method + * * @return the bean property name */ public static String getPropertyName(Method setter) { @@ -53,19 +52,15 @@ public class Introspection { /** - * Determines if a method has a valid name and signature for a Java Bean - * setter. + * Determines if a method has a valid name and signature for a Java Bean setter. * - * @param method The method to test + * @param method The method to test * - * @return <code>true</code> if the method does have a valid name and - * signature, else <code>false</code> + * @return <code>true</code> if the method does have a valid name and signature, else <code>false</code> */ public static boolean isValidSetter(Method method) { - if (method.getName().startsWith("set") - && method.getName().length() > 3 - && method.getParameterTypes().length == 1 - && method.getReturnType().getName().equals("void")) { + if (method.getName().startsWith("set") && method.getName().length() > 3 && + method.getParameterTypes().length == 1 && method.getReturnType().getName().equals("void")) { return true; } return false; @@ -74,26 +69,23 @@ public class Introspection { /** * Determines if a method is a valid lifecycle callback method. * - * @param method - * The method to test + * @param method The method to test * - * @return <code>true</code> if the method is a valid lifecycle callback - * method, else <code>false</code> + * @return <code>true</code> if the method is a valid lifecycle callback method, else <code>false</code> */ public static boolean isValidLifecycleCallback(Method method) { - if (method.getParameterTypes().length != 0 - || Modifier.isStatic(method.getModifiers()) - || method.getExceptionTypes().length > 0 - || !method.getReturnType().getName().equals("void")) { + if (method.getParameterTypes().length != 0 || Modifier.isStatic(method.getModifiers()) || + method.getExceptionTypes().length > 0 || !method.getReturnType().getName().equals("void")) { return false; } return true; } /** - * Obtain the declared fields for a class taking account of any security - * manager that may be configured. + * Obtain the declared fields for a class taking account of any security manager that may be configured. + * * @param clazz The class to introspect + * * @return the class fields as an array */ public static Field[] getDeclaredFields(final Class<?> clazz) { @@ -108,9 +100,10 @@ public class Introspection { /** - * Obtain the declared methods for a class taking account of any security - * manager that may be configured. + * Obtain the declared methods for a class taking account of any security manager that may be configured. + * * @param clazz The class to introspect + * * @return the class methods as an array */ public static Method[] getDeclaredMethods(final Class<?> clazz) { @@ -125,12 +118,12 @@ public class Introspection { /** - * Attempt to load a class using the given Container's class loader. If the - * class cannot be loaded, a debug level log message will be written to the - * Container's log and null will be returned. - * @param context The class loader of this context will be used to attempt - * to load the class + * Attempt to load a class using the given Container's class loader. If the class cannot be loaded, a debug level + * log message will be written to the Container's log and null will be returned. + * + * @param context The class loader of this context will be used to attempt to load the class * @param className The class name + * * @return the loaded class or <code>null</code> if loading failed */ public static Class<?> loadClass(Context context, String className) { @@ -151,10 +144,9 @@ public class Introspection { /** * Converts the primitive type to its corresponding wrapper. * - * @param clazz - * Class that will be evaluated - * @return if the parameter is a primitive type returns its wrapper; - * otherwise returns the same class + * @param clazz Class that will be evaluated + * + * @return if the parameter is a primitive type returns its wrapper; otherwise returns the same class */ public static Class<?> convertPrimitiveType(Class<?> clazz) { if (clazz.equals(char.class)) { diff --git a/java/org/apache/catalina/util/LifecycleBase.java b/java/org/apache/catalina/util/LifecycleBase.java index f25af03fa5..ec7abb1b22 100644 --- a/java/org/apache/catalina/util/LifecycleBase.java +++ b/java/org/apache/catalina/util/LifecycleBase.java @@ -30,9 +30,8 @@ import org.apache.tomcat.util.ExceptionUtils; import org.apache.tomcat.util.res.StringManager; /** - * Base implementation of the {@link Lifecycle} interface that implements the - * state transition rules for {@link Lifecycle#start()} and - * {@link Lifecycle#stop()} + * Base implementation of the {@link Lifecycle} interface that implements the state transition rules for + * {@link Lifecycle#start()} and {@link Lifecycle#stop()} */ public abstract class LifecycleBase implements Lifecycle { @@ -57,13 +56,11 @@ public abstract class LifecycleBase implements Lifecycle { /** - * Will a {@link LifecycleException} thrown by a sub-class during - * {@link #initInternal()}, {@link #startInternal()}, - * {@link #stopInternal()} or {@link #destroyInternal()} be re-thrown for - * the caller to handle or will it be logged instead? + * Will a {@link LifecycleException} thrown by a sub-class during {@link #initInternal()}, {@link #startInternal()}, + * {@link #stopInternal()} or {@link #destroyInternal()} be re-thrown for the caller to handle or will it be logged + * instead? * - * @return {@code true} if the exception will be re-thrown, otherwise - * {@code false} + * @return {@code true} if the exception will be re-thrown, otherwise {@code false} */ public boolean getThrowOnFailure() { return throwOnFailure; @@ -71,13 +68,11 @@ public abstract class LifecycleBase implements Lifecycle { /** - * Configure if a {@link LifecycleException} thrown by a sub-class during - * {@link #initInternal()}, {@link #startInternal()}, - * {@link #stopInternal()} or {@link #destroyInternal()} will be re-thrown - * for the caller to handle or if it will be logged instead. + * Configure if a {@link LifecycleException} thrown by a sub-class during {@link #initInternal()}, + * {@link #startInternal()}, {@link #stopInternal()} or {@link #destroyInternal()} will be re-thrown for the caller + * to handle or if it will be logged instead. * - * @param throwOnFailure {@code true} if the exception should be re-thrown, - * otherwise {@code false} + * @param throwOnFailure {@code true} if the exception should be re-thrown, otherwise {@code false} */ public void setThrowOnFailure(boolean throwOnFailure) { this.throwOnFailure = throwOnFailure; @@ -105,8 +100,8 @@ public abstract class LifecycleBase implements Lifecycle { /** * Allow sub classes to fire {@link Lifecycle} events. * - * @param type Event type - * @param data Data associated with event. + * @param type Event type + * @param data Data associated with event. */ protected void fireLifecycleEvent(String type, Object data) { LifecycleEvent event = new LifecycleEvent(this, type, data); @@ -133,8 +128,7 @@ public abstract class LifecycleBase implements Lifecycle { /** - * Sub-classes implement this method to perform any instance initialisation - * required. + * Sub-classes implement this method to perform any instance initialisation required. * * @throws LifecycleException If the initialisation fails */ @@ -161,8 +155,7 @@ public abstract class LifecycleBase implements Lifecycle { init(); } else if (state.equals(LifecycleState.FAILED)) { stop(); - } else if (!state.equals(LifecycleState.INITIALIZED) && - !state.equals(LifecycleState.STOPPED)) { + } else if (!state.equals(LifecycleState.INITIALIZED) && !state.equals(LifecycleState.STOPPED)) { invalidTransition(BEFORE_START_EVENT); } @@ -189,15 +182,11 @@ public abstract class LifecycleBase implements Lifecycle { /** - * Sub-classes must ensure that the state is changed to - * {@link LifecycleState#STARTING} during the execution of this method. - * Changing state will trigger the {@link Lifecycle#START_EVENT} event. - * - * If a component fails to start it may either throw a - * {@link LifecycleException} which will cause it's parent to fail to start - * or it can place itself in the error state in which case {@link #stop()} - * will be called on the failed component but the parent component will - * continue to start normally. + * Sub-classes must ensure that the state is changed to {@link LifecycleState#STARTING} during the execution of this + * method. Changing state will trigger the {@link Lifecycle#START_EVENT} event. If a component fails to start it may + * either throw a {@link LifecycleException} which will cause it's parent to fail to start or it can place itself in + * the error state in which case {@link #stop()} will be called on the failed component but the parent component + * will continue to start normally. * * @throws LifecycleException Start error occurred */ @@ -261,9 +250,8 @@ public abstract class LifecycleBase implements Lifecycle { /** - * Sub-classes must ensure that the state is changed to - * {@link LifecycleState#STOPPING} during the execution of this method. - * Changing state will trigger the {@link Lifecycle#STOP_EVENT} event. + * Sub-classes must ensure that the state is changed to {@link LifecycleState#STOPPING} during the execution of this + * method. Changing state will trigger the {@link Lifecycle#STOP_EVENT} event. * * @throws LifecycleException Stop error occurred */ @@ -312,8 +300,7 @@ public abstract class LifecycleBase implements Lifecycle { /** - * Sub-classes implement this method to perform any instance destruction - * required. + * Sub-classes implement this method to perform any instance destruction required. * * @throws LifecycleException If the destruction fails */ @@ -333,12 +320,12 @@ public abstract class LifecycleBase implements Lifecycle { /** - * Provides a mechanism for sub-classes to update the component state. - * Calling this method will automatically fire any associated - * {@link Lifecycle} event. It will also check that any attempted state - * transition is valid for a sub-class. + * Provides a mechanism for sub-classes to update the component state. Calling this method will automatically fire + * any associated {@link Lifecycle} event. It will also check that any attempted state transition is valid for a + * sub-class. * * @param state The new state for this component + * * @throws LifecycleException when attempting to set an invalid state */ protected synchronized void setState(LifecycleState state) throws LifecycleException { @@ -347,17 +334,16 @@ public abstract class LifecycleBase implements Lifecycle { /** - * Provides a mechanism for sub-classes to update the component state. - * Calling this method will automatically fire any associated - * {@link Lifecycle} event. It will also check that any attempted state - * transition is valid for a sub-class. + * Provides a mechanism for sub-classes to update the component state. Calling this method will automatically fire + * any associated {@link Lifecycle} event. It will also check that any attempted state transition is valid for a + * sub-class. * * @param state The new state for this component * @param data The data to pass to the associated {@link Lifecycle} event + * * @throws LifecycleException when attempting to set an invalid state */ - protected synchronized void setState(LifecycleState state, Object data) - throws LifecycleException { + protected synchronized void setState(LifecycleState state, Object data) throws LifecycleException { setStateInternal(state, data, true); } @@ -385,12 +371,9 @@ public abstract class LifecycleBase implements Lifecycle { // stopInternal() permits STOPPING_PREP to STOPPING and FAILED to // STOPPING if (!(state == LifecycleState.FAILED || - (this.state == LifecycleState.STARTING_PREP && - state == LifecycleState.STARTING) || - (this.state == LifecycleState.STOPPING_PREP && - state == LifecycleState.STOPPING) || - (this.state == LifecycleState.FAILED && - state == LifecycleState.STOPPING))) { + (this.state == LifecycleState.STARTING_PREP && state == LifecycleState.STARTING) || + (this.state == LifecycleState.STOPPING_PREP && state == LifecycleState.STOPPING) || + (this.state == LifecycleState.FAILED && state == LifecycleState.STOPPING))) { // No other transition permitted invalidTransition(state.name()); } diff --git a/java/org/apache/catalina/util/LifecycleMBeanBase.java b/java/org/apache/catalina/util/LifecycleMBeanBase.java index d8a2abd45d..fe50794d0f 100644 --- a/java/org/apache/catalina/util/LifecycleMBeanBase.java +++ b/java/org/apache/catalina/util/LifecycleMBeanBase.java @@ -27,13 +27,11 @@ import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.modeler.Registry; import org.apache.tomcat.util.res.StringManager; -public abstract class LifecycleMBeanBase extends LifecycleBase - implements JmxEnabled { +public abstract class LifecycleMBeanBase extends LifecycleBase implements JmxEnabled { private static final Log log = LogFactory.getLog(LifecycleMBeanBase.class); - private static final StringManager sm = - StringManager.getManager("org.apache.catalina.util"); + private static final StringManager sm = StringManager.getManager("org.apache.catalina.util"); /* Cache components of the MBean registration. */ @@ -81,10 +79,9 @@ public abstract class LifecycleMBeanBase extends LifecycleBase /** - * Method implemented by sub-classes to identify the domain in which MBeans - * should be registered. + * Method implemented by sub-classes to identify the domain in which MBeans should be registered. * - * @return The name of the domain to use to register MBeans. + * @return The name of the domain to use to register MBeans. */ protected abstract String getDomainInternal(); @@ -96,31 +93,26 @@ public abstract class LifecycleMBeanBase extends LifecycleBase /** - * Allow sub-classes to specify the key properties component of the - * {@link ObjectName} that will be used to register this component. + * Allow sub-classes to specify the key properties component of the {@link ObjectName} that will be used to register + * this component. * - * @return The string representation of the key properties component of the - * desired {@link ObjectName} + * @return The string representation of the key properties component of the desired {@link ObjectName} */ protected abstract String getObjectNameKeyProperties(); /** - * Utility method to enable sub-classes to easily register additional - * components that don't implement {@link JmxEnabled} with an MBean server. - * <br> - * Note: This method should only be used once {@link #initInternal()} has - * been called and before {@link #destroyInternal()} has been called. + * Utility method to enable sub-classes to easily register additional components that don't implement + * {@link JmxEnabled} with an MBean server. <br> + * Note: This method should only be used once {@link #initInternal()} has been called and before + * {@link #destroyInternal()} has been called. * - * @param obj The object the register - * @param objectNameKeyProperties The key properties component of the - * object name to use to register the - * object + * @param obj The object the register + * @param objectNameKeyProperties The key properties component of the object name to use to register the object * - * @return The name used to register the object + * @return The name used to register the object */ - protected final ObjectName register(Object obj, - String objectNameKeyProperties) { + protected final ObjectName register(Object obj, String objectNameKeyProperties) { // Construct an object name with the right domain StringBuilder name = new StringBuilder(getDomain()); @@ -141,15 +133,12 @@ public abstract class LifecycleMBeanBase extends LifecycleBase /** - * Utility method to enable sub-classes to easily unregister additional - * components that don't implement {@link JmxEnabled} with an MBean server. - * <br> - * Note: This method should only be used once {@link #initInternal()} has - * been called and before {@link #destroyInternal()} has been called. + * Utility method to enable sub-classes to easily unregister additional components that don't implement + * {@link JmxEnabled} with an MBean server. <br> + * Note: This method should only be used once {@link #initInternal()} has been called and before + * {@link #destroyInternal()} has been called. * - * @param objectNameKeyProperties The key properties component of the - * object name to use to unregister the - * object + * @param objectNameKeyProperties The key properties component of the object name to use to unregister the object */ protected final void unregister(String objectNameKeyProperties) { // Construct an object name with the right domain @@ -161,13 +150,12 @@ public abstract class LifecycleMBeanBase extends LifecycleBase /** - * Utility method to enable sub-classes to easily unregister additional - * components that don't implement {@link JmxEnabled} with an MBean server. - * <br> - * Note: This method should only be used once {@link #initInternal()} has - * been called and before {@link #destroyInternal()} has been called. + * Utility method to enable sub-classes to easily unregister additional components that don't implement + * {@link JmxEnabled} with an MBean server. <br> + * Note: This method should only be used once {@link #initInternal()} has been called and before + * {@link #destroyInternal()} has been called. * - * @param on The name of the component to unregister + * @param on The name of the component to unregister */ protected final void unregister(ObjectName on) { Registry.getRegistry(null, null).unregisterComponent(on); @@ -202,8 +190,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase @Override - public final ObjectName preRegister(MBeanServer server, ObjectName name) - throws Exception { + public final ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { this.mserver = server; this.oname = name; diff --git a/java/org/apache/catalina/util/ManifestResource.java b/java/org/apache/catalina/util/ManifestResource.java index d4c80de825..36559dc7c5 100644 --- a/java/org/apache/catalina/util/ManifestResource.java +++ b/java/org/apache/catalina/util/ManifestResource.java @@ -21,8 +21,7 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; /** - * Representation of a Manifest file and its available extensions and - * required extensions + * Representation of a Manifest file and its available extensions and required extensions * * @author Greg Murray * @author Justyna Horwat @@ -42,8 +41,7 @@ public class ManifestResource { private final String resourceName; private final int resourceType; - public ManifestResource(String resourceName, Manifest manifest, - int resourceType) { + public ManifestResource(String resourceName, Manifest manifest, int resourceType) { this.resourceName = resourceName; this.resourceType = resourceType; processManifest(manifest); @@ -97,8 +95,8 @@ public class ManifestResource { } /** - * Returns <code>true</code> if all required extension dependencies - * have been meet for this <code>ManifestResource</code> object. + * Returns <code>true</code> if all required extension dependencies have been meet for this + * <code>ManifestResource</code> object. * * @return boolean true if all extension dependencies have been satisfied */ @@ -120,15 +118,21 @@ public class ManifestResource { sb.append(resourceName); sb.append(", isFulfilled="); - sb.append(isFulfilled() +""); + sb.append(isFulfilled() + ""); sb.append(", requiredExtensionCount ="); sb.append(getRequiredExtensionCount()); sb.append(", availableExtensionCount="); sb.append(getAvailableExtensionCount()); switch (resourceType) { - case SYSTEM : sb.append(", resourceType=SYSTEM"); break; - case WAR : sb.append(", resourceType=WAR"); break; - case APPLICATION : sb.append(", resourceType=APPLICATION"); break; + case SYSTEM: + sb.append(", resourceType=SYSTEM"); + break; + case WAR: + sb.append(", resourceType=WAR"); + break; + case APPLICATION: + sb.append(", resourceType=APPLICATION"); + break; } sb.append(']'); return sb.toString(); @@ -143,14 +147,12 @@ public class ManifestResource { } /** - * Return the set of <code>Extension</code> objects representing optional - * packages that are required by the application associated with the - * specified <code>Manifest</code>. + * Return the set of <code>Extension</code> objects representing optional packages that are required by the + * application associated with the specified <code>Manifest</code>. * * @param manifest Manifest to be parsed * - * @return List of required extensions, or null if the application - * does not require any extensions + * @return List of required extensions, or null if the application does not require any extensions */ private ArrayList<Extension> getRequiredExtensions(Manifest manifest) { @@ -172,35 +174,29 @@ public class ManifestResource { String name = names.substring(0, space).trim(); names = names.substring(space + 1); - String value = - attributes.getValue(name + "-Extension-Name"); + String value = attributes.getValue(name + "-Extension-Name"); if (value == null) { continue; } Extension extension = new Extension(); extension.setExtensionName(value); - extension.setImplementationURL - (attributes.getValue(name + "-Implementation-URL")); - extension.setImplementationVendorId - (attributes.getValue(name + "-Implementation-Vendor-Id")); + extension.setImplementationURL(attributes.getValue(name + "-Implementation-URL")); + extension.setImplementationVendorId(attributes.getValue(name + "-Implementation-Vendor-Id")); String version = attributes.getValue(name + "-Implementation-Version"); extension.setImplementationVersion(version); - extension.setSpecificationVersion - (attributes.getValue(name + "-Specification-Version")); + extension.setSpecificationVersion(attributes.getValue(name + "-Specification-Version")); extensionList.add(extension); } return extensionList; } /** - * Return the set of <code>Extension</code> objects representing optional - * packages that are bundled with the application associated with the - * specified <code>Manifest</code>. + * Return the set of <code>Extension</code> objects representing optional packages that are bundled with the + * application associated with the specified <code>Manifest</code>. * * @param manifest Manifest to be parsed * - * @return List of available extensions, or null if the web application - * does not bundle any extensions + * @return List of available extensions, or null if the web application does not bundle any extensions */ private ArrayList<Extension> getAvailableExtensions(Manifest manifest) { @@ -214,16 +210,11 @@ public class ManifestResource { Extension extension = new Extension(); extension.setExtensionName(name); - extension.setImplementationURL( - attributes.getValue("Implementation-URL")); - extension.setImplementationVendor( - attributes.getValue("Implementation-Vendor")); - extension.setImplementationVendorId( - attributes.getValue("Implementation-Vendor-Id")); - extension.setImplementationVersion( - attributes.getValue("Implementation-Version")); - extension.setSpecificationVersion( - attributes.getValue("Specification-Version")); + extension.setImplementationURL(attributes.getValue("Implementation-URL")); + extension.setImplementationVendor(attributes.getValue("Implementation-Vendor")); + extension.setImplementationVendorId(attributes.getValue("Implementation-Vendor-Id")); + extension.setImplementationVersion(attributes.getValue("Implementation-Version")); + extension.setSpecificationVersion(attributes.getValue("Specification-Version")); extensionList.add(extension); diff --git a/java/org/apache/catalina/util/ParameterMap.java b/java/org/apache/catalina/util/ParameterMap.java index 5e09295539..208893ab2d 100644 --- a/java/org/apache/catalina/util/ParameterMap.java +++ b/java/org/apache/catalina/util/ParameterMap.java @@ -26,18 +26,16 @@ import java.util.Set; import org.apache.tomcat.util.res.StringManager; /** - * Implementation of <strong>java.util.Map</strong> that includes a - * <code>locked</code> property. This class can be used to safely expose - * Catalina internal parameter map objects to user classes without having - * to clone them in order to avoid modifications. When first created, a - * <code>ParameterMap</code> instance is not locked. + * Implementation of <strong>java.util.Map</strong> that includes a <code>locked</code> property. This class can be used + * to safely expose Catalina internal parameter map objects to user classes without having to clone them in order to + * avoid modifications. When first created, a <code>ParameterMap</code> instance is not locked. * * @param <K> The type of Key * @param <V> The type of Value * * @author Craig R. McClanahan */ -public final class ParameterMap<K,V> implements Map<K,V>, Serializable { +public final class ParameterMap<K, V> implements Map<K,V>, Serializable { private static final long serialVersionUID = 2L; @@ -47,8 +45,7 @@ public final class ParameterMap<K,V> implements Map<K,V>, Serializable { /** - * Construct a new, empty map with the default initial capacity and - * load factor. + * Construct a new, empty map with the default initial capacity and load factor. */ public ParameterMap() { delegatedMap = new LinkedHashMap<>(); @@ -57,8 +54,7 @@ public final class ParameterMap<K,V> implements Map<K,V>, Serializable { /** - * Construct a new, empty map with the specified initial capacity and - * default load factor. + * Construct a new, empty map with the specified initial capacity and default load factor. * * @param initialCapacity The initial capacity of this map */ @@ -69,11 +65,10 @@ public final class ParameterMap<K,V> implements Map<K,V>, Serializable { /** - * Construct a new, empty map with the specified initial capacity and - * load factor. + * Construct a new, empty map with the specified initial capacity and load factor. * * @param initialCapacity The initial capacity of this map - * @param loadFactor The load factor of this map + * @param loadFactor The load factor of this map */ public ParameterMap(int initialCapacity, float loadFactor) { delegatedMap = new LinkedHashMap<>(initialCapacity, loadFactor); @@ -210,8 +205,7 @@ public final class ParameterMap<K,V> implements Map<K,V>, Serializable { /** * {@inheritDoc} * <p> - * Returns an <strong>unmodifiable</strong> {@link Set} view of the keys - * contained in this map if it is locked. + * Returns an <strong>unmodifiable</strong> {@link Set} view of the keys contained in this map if it is locked. */ @Override public Set<K> keySet() { @@ -226,8 +220,8 @@ public final class ParameterMap<K,V> implements Map<K,V>, Serializable { /** * {@inheritDoc} * <p> - * Returns an <strong>unmodifiable</strong> {@link Collection} view of the - * values contained in this map if it is locked. + * Returns an <strong>unmodifiable</strong> {@link Collection} view of the values contained in this map if it is + * locked. */ @Override public Collection<V> values() { @@ -242,11 +236,10 @@ public final class ParameterMap<K,V> implements Map<K,V>, Serializable { /** * {@inheritDoc} * <p> - * Returns an <strong>unmodifiable</strong> {@link Set} view of the mappings - * contained in this map if it is locked. + * Returns an <strong>unmodifiable</strong> {@link Set} view of the mappings contained in this map if it is locked. */ @Override - public Set<Map.Entry<K, V>> entrySet() { + public Set<Map.Entry<K,V>> entrySet() { if (locked) { return unmodifiableDelegatedMap.entrySet(); } diff --git a/java/org/apache/catalina/util/RequestUtil.java b/java/org/apache/catalina/util/RequestUtil.java index ce6ffa7e42..74e762780d 100644 --- a/java/org/apache/catalina/util/RequestUtil.java +++ b/java/org/apache/catalina/util/RequestUtil.java @@ -27,10 +27,8 @@ import javax.servlet.http.HttpServletRequest; public final class RequestUtil { /** - * Build an appropriate return value for - * {@link HttpServletRequest#getRequestURL()} based on the provided - * request object. Note that this will also work for instances of - * {@link javax.servlet.http.HttpServletRequestWrapper}. + * Build an appropriate return value for {@link HttpServletRequest#getRequestURL()} based on the provided request + * object. Note that this will also work for instances of {@link javax.servlet.http.HttpServletRequestWrapper}. * * @param request The request object for which the URL should be built * @@ -48,8 +46,7 @@ public final class RequestUtil { url.append(scheme); url.append("://"); url.append(request.getServerName()); - if ((scheme.equals("http") && (port != 80)) - || (scheme.equals("https") && (port != 443))) { + if ((scheme.equals("http") && (port != 80)) || (scheme.equals("https") && (port != 443))) { url.append(':'); url.append(port); } diff --git a/java/org/apache/catalina/util/ResourceSet.java b/java/org/apache/catalina/util/ResourceSet.java index e97fd0880e..c6a343df23 100644 --- a/java/org/apache/catalina/util/ResourceSet.java +++ b/java/org/apache/catalina/util/ResourceSet.java @@ -24,11 +24,9 @@ import org.apache.tomcat.util.res.StringManager; /** - * Extended implementation of <strong>HashSet</strong> that includes a - * <code>locked</code> property. This class can be used to safely expose - * resource path sets to user classes without having to clone them in order - * to avoid modifications. When first created, a <code>ResourceMap</code> - * is not locked. + * Extended implementation of <strong>HashSet</strong> that includes a <code>locked</code> property. This class can be + * used to safely expose resource path sets to user classes without having to clone them in order to avoid + * modifications. When first created, a <code>ResourceMap</code> is not locked. * * @param <T> The type of elements in the Set * @@ -40,8 +38,7 @@ public final class ResourceSet<T> extends HashSet<T> { // ----------------------------------------------------------- Constructors /** - * Construct a new, empty set with the default initial capacity and - * load factor. + * Construct a new, empty set with the default initial capacity and load factor. */ public ResourceSet() { @@ -51,8 +48,7 @@ public final class ResourceSet<T> extends HashSet<T> { /** - * Construct a new, empty set with the specified initial capacity and - * default load factor. + * Construct a new, empty set with the specified initial capacity and default load factor. * * @param initialCapacity The initial capacity of this set */ @@ -64,11 +60,10 @@ public final class ResourceSet<T> extends HashSet<T> { /** - * Construct a new, empty set with the specified initial capacity and - * load factor. + * Construct a new, empty set with the specified initial capacity and load factor. * * @param initialCapacity The initial capacity of this set - * @param loadFactor The load factor of this set + * @param loadFactor The load factor of this set */ public ResourceSet(int initialCapacity, float loadFactor) { @@ -119,8 +114,7 @@ public final class ResourceSet<T> extends HashSet<T> { /** * The string manager for this package. */ - private static final StringManager sm = - StringManager.getManager("org.apache.catalina.util"); + private static final StringManager sm = StringManager.getManager("org.apache.catalina.util"); // --------------------------------------------------------- Public Methods @@ -134,8 +128,7 @@ public final class ResourceSet<T> extends HashSet<T> { @Override public boolean add(T o) { if (locked) { - throw new IllegalStateException - (sm.getString("resourceSet.locked")); + throw new IllegalStateException(sm.getString("resourceSet.locked")); } return super.add(o); } @@ -150,8 +143,7 @@ public final class ResourceSet<T> extends HashSet<T> { public void clear() { if (locked) { - throw new IllegalStateException - (sm.getString("resourceSet.locked")); + throw new IllegalStateException(sm.getString("resourceSet.locked")); } super.clear(); @@ -166,8 +158,7 @@ public final class ResourceSet<T> extends HashSet<T> { @Override public boolean remove(Object o) { if (locked) { - throw new IllegalStateException - (sm.getString("resourceSet.locked")); + throw new IllegalStateException(sm.getString("resourceSet.locked")); } return super.remove(o); } diff --git a/java/org/apache/catalina/util/ServerInfo.java b/java/org/apache/catalina/util/ServerInfo.java index d55bd8ed6d..b326ad4910 100644 --- a/java/org/apache/catalina/util/ServerInfo.java +++ b/java/org/apache/catalina/util/ServerInfo.java @@ -24,8 +24,7 @@ import org.apache.tomcat.util.ExceptionUtils; /** - * Simple utility module to make it easy to plug in the server identifier - * when integrating Tomcat. + * Simple utility module to make it easy to plug in the server identifier when integrating Tomcat. * * @author Craig R. McClanahan */ @@ -63,8 +62,7 @@ public class ServerInfo { String number = null; Properties props = new Properties(); - try (InputStream is = ServerInfo.class.getResourceAsStream - ("/org/apache/catalina/util/ServerInfo.properties")) { + try (InputStream is = ServerInfo.class.getResourceAsStream("/org/apache/catalina/util/ServerInfo.properties")) { props.load(is); info = props.getProperty("server.info"); built = props.getProperty("server.built"); @@ -128,16 +126,11 @@ public class ServerInfo { System.out.println("Server version: " + getServerInfo()); System.out.println("Server built: " + getServerBuilt()); System.out.println("Server number: " + getServerNumber()); - System.out.println("OS Name: " + - System.getProperty("os.name")); - System.out.println("OS Version: " + - System.getProperty("os.version")); - System.out.println("Architecture: " + - System.getProperty("os.arch")); - System.out.println("JVM Version: " + - System.getProperty("java.runtime.version")); - System.out.println("JVM Vendor: " + - System.getProperty("java.vm.vendor")); + System.out.println("OS Name: " + System.getProperty("os.name")); + System.out.println("OS Version: " + System.getProperty("os.version")); + System.out.println("Architecture: " + System.getProperty("os.arch")); + System.out.println("JVM Version: " + System.getProperty("java.runtime.version")); + System.out.println("JVM Vendor: " + System.getProperty("java.vm.vendor")); } } diff --git a/java/org/apache/catalina/util/SessionConfig.java b/java/org/apache/catalina/util/SessionConfig.java index 932c115820..45b5ed1cf0 100644 --- a/java/org/apache/catalina/util/SessionConfig.java +++ b/java/org/apache/catalina/util/SessionConfig.java @@ -26,9 +26,10 @@ public class SessionConfig { private static final String DEFAULT_SESSION_PARAMETER_NAME = "jsessionid"; /** - * Determine the name to use for the session cookie for the provided - * context. + * Determine the name to use for the session cookie for the provided context. + * * @param context The context + * * @return the cookie name for the context */ public static String getSessionCookieName(Context context) { @@ -36,9 +37,10 @@ public class SessionConfig { } /** - * Determine the name to use for the session path parameter for the provided - * context. + * Determine the name to use for the session path parameter for the provided context. + * * @param context The context + * * @return the parameter name for the session */ public static String getSessionUriParamName(Context context) { @@ -68,10 +70,10 @@ public class SessionConfig { /** - * Determine the value to use for the session cookie path for the provided - * context. + * Determine the value to use for the session cookie path for the provided context. * * @param context The context + * * @return the parameter name for the session */ public static String getSessionCookiePath(Context context) { diff --git a/java/org/apache/catalina/util/SessionIdGeneratorBase.java b/java/org/apache/catalina/util/SessionIdGeneratorBase.java index 87d0a575be..d2d4198337 100644 --- a/java/org/apache/catalina/util/SessionIdGeneratorBase.java +++ b/java/org/apache/catalina/util/SessionIdGeneratorBase.java @@ -41,10 +41,9 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se static { /* - * The default is normally SHA1PRNG. This was chosen because a) it is - * quick and b) it available by default in all JREs. However, it may not - * be available in some configurations such as those that use a FIPS - * certified provider. In those cases, use the platform default. + * The default is normally SHA1PRNG. This was chosen because a) it is quick and b) it available by default in + * all JREs. However, it may not be available in some configurations such as those that use a FIPS certified + * provider. In those cases, use the platform default. */ Set<String> algorithmNames = Security.getAlgorithms("SecureRandom"); if (algorithmNames.contains("SHA1PRNG")) { @@ -58,11 +57,10 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se } /** - * Queue of random number generator objects to be used when creating session - * identifiers. If the queue is empty when a random number generator is - * required, a new random number generator object is created. This is - * designed this way since random number generators use a sync to make them - * thread-safe and the sync makes using a single object slow(er). + * Queue of random number generator objects to be used when creating session identifiers. If the queue is empty when + * a random number generator is required, a new random number generator object is created. This is designed this way + * since random number generators use a sync to make them thread-safe and the sync makes using a single object + * slow(er). */ private final Queue<SecureRandom> randoms = new ConcurrentLinkedQueue<>(); @@ -82,11 +80,10 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se /** - * Get the class name of the {@link SecureRandom} implementation used to - * generate session IDs. + * Get the class name of the {@link SecureRandom} implementation used to generate session IDs. * - * @return The fully qualified class name. {@code null} indicates that the - * JRE provided {@link SecureRandom} implementation will be used + * @return The fully qualified class name. {@code null} indicates that the JRE provided {@link SecureRandom} + * implementation will be used */ public String getSecureRandomClass() { return secureRandomClass; @@ -94,9 +91,8 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se /** - * Specify a non-default {@link SecureRandom} implementation to use. The - * implementation must be self-seeding and have a zero-argument constructor. - * If not specified, an instance of {@link SecureRandom} will be generated. + * Specify a non-default {@link SecureRandom} implementation to use. The implementation must be self-seeding and + * have a zero-argument constructor. If not specified, an instance of {@link SecureRandom} will be generated. * * @param secureRandomClass The fully-qualified class name */ @@ -106,11 +102,9 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se /** - * Get the name of the algorithm used to create the {@link SecureRandom} - * instances which generate new session IDs. + * Get the name of the algorithm used to create the {@link SecureRandom} instances which generate new session IDs. * - * @return The name of the algorithm. {@code null} or the empty string means - * that platform default will be used + * @return The name of the algorithm. {@code null} or the empty string means that platform default will be used */ public String getSecureRandomAlgorithm() { return secureRandomAlgorithm; @@ -118,15 +112,12 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se /** - * Specify a non-default algorithm to use to create instances of - * {@link SecureRandom} which are used to generate session IDs. If no - * algorithm is specified, SHA1PRNG will be used. If SHA1PRNG is not - * available, the platform default will be used. To use the platform default - * (which may be SHA1PRNG), specify {@code null} or the empty string. If an - * invalid algorithm and/or provider is specified the {@link SecureRandom} - * instances will be created using the defaults for this - * {@link SessionIdGenerator} implementation. If that fails, the - * {@link SecureRandom} instances will be created using platform defaults. + * Specify a non-default algorithm to use to create instances of {@link SecureRandom} which are used to generate + * session IDs. If no algorithm is specified, SHA1PRNG will be used. If SHA1PRNG is not available, the platform + * default will be used. To use the platform default (which may be SHA1PRNG), specify {@code null} or the empty + * string. If an invalid algorithm and/or provider is specified the {@link SecureRandom} instances will be created + * using the defaults for this {@link SessionIdGenerator} implementation. If that fails, the {@link SecureRandom} + * instances will be created using platform defaults. * * @param secureRandomAlgorithm The name of the algorithm */ @@ -136,11 +127,9 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se /** - * Get the name of the provider used to create the {@link SecureRandom} - * instances which generate new session IDs. + * Get the name of the provider used to create the {@link SecureRandom} instances which generate new session IDs. * - * @return The name of the provider. {@code null} or the empty string means - * that platform default will be used + * @return The name of the provider. {@code null} or the empty string means that platform default will be used */ public String getSecureRandomProvider() { return secureRandomProvider; @@ -148,16 +137,13 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se /** - * Specify a non-default provider to use to create instances of - * {@link SecureRandom} which are used to generate session IDs. If no - * provider is specified, the platform default is used. To use the platform - * default specify {@code null} or the empty string. If an invalid algorithm - * and/or provider is specified the {@link SecureRandom} instances will be - * created using the defaults for this {@link SessionIdGenerator} - * implementation. If that fails, the {@link SecureRandom} instances will be - * created using platform defaults. + * Specify a non-default provider to use to create instances of {@link SecureRandom} which are used to generate + * session IDs. If no provider is specified, the platform default is used. To use the platform default specify + * {@code null} or the empty string. If an invalid algorithm and/or provider is specified the {@link SecureRandom} + * instances will be created using the defaults for this {@link SessionIdGenerator} implementation. If that fails, + * the {@link SecureRandom} instances will be created using platform defaults. * - * @param secureRandomProvider The name of the provider + * @param secureRandomProvider The name of the provider */ public void setSecureRandomProvider(String secureRandomProvider) { this.secureRandomProvider = secureRandomProvider; @@ -205,8 +191,7 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se /** - * Create a new random number generator instance we should use for - * generating session identifiers. + * Create a new random number generator instance we should use for generating session identifiers. */ private SecureRandom createSecureRandom() { @@ -219,8 +204,7 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se Class<?> clazz = Class.forName(secureRandomClass); result = (SecureRandom) clazz.getConstructor().newInstance(); } catch (Exception e) { - log.error(sm.getString("sessionIdGeneratorBase.random", - secureRandomClass), e); + log.error(sm.getString("sessionIdGeneratorBase.random", secureRandomClass), e); } } @@ -228,22 +212,17 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se if (result == null) { // No secureRandomClass or creation failed. Use SecureRandom. try { - if (secureRandomProvider != null && - secureRandomProvider.length() > 0) { - result = SecureRandom.getInstance(secureRandomAlgorithm, - secureRandomProvider); - } else if (secureRandomAlgorithm != null && - secureRandomAlgorithm.length() > 0) { + if (secureRandomProvider != null && secureRandomProvider.length() > 0) { + result = SecureRandom.getInstance(secureRandomAlgorithm, secureRandomProvider); + } else if (secureRandomAlgorithm != null && secureRandomAlgorithm.length() > 0) { result = SecureRandom.getInstance(secureRandomAlgorithm); } } catch (NoSuchAlgorithmException e) { error = true; - log.error(sm.getString("sessionIdGeneratorBase.randomAlgorithm", - secureRandomAlgorithm), e); + log.error(sm.getString("sessionIdGeneratorBase.randomAlgorithm", secureRandomAlgorithm), e); } catch (NoSuchProviderException e) { error = true; - log.error(sm.getString("sessionIdGeneratorBase.randomProvider", - secureRandomProvider), e); + log.error(sm.getString("sessionIdGeneratorBase.randomProvider", secureRandomProvider), e); } } @@ -254,8 +233,7 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se try { result = SecureRandom.getInstance(DEFAULT_SECURE_RANDOM_ALGORITHM); } catch (NoSuchAlgorithmException e) { - log.error(sm.getString("sessionIdGeneratorBase.randomAlgorithm", - secureRandomAlgorithm), e); + log.error(sm.getString("sessionIdGeneratorBase.randomAlgorithm", secureRandomAlgorithm), e); } } @@ -269,8 +247,7 @@ public abstract class SessionIdGeneratorBase extends LifecycleBase implements Se long t2 = System.currentTimeMillis(); if ((t2 - t1) > 100) { - log.warn(sm.getString("sessionIdGeneratorBase.createRandom", - result.getAlgorithm(), Long.valueOf(t2 - t1))); + log.warn(sm.getString("sessionIdGeneratorBase.createRandom", result.getAlgorithm(), Long.valueOf(t2 - t1))); } return result; } diff --git a/java/org/apache/catalina/util/StandardSessionIdGenerator.java b/java/org/apache/catalina/util/StandardSessionIdGenerator.java index ea6ea65e9c..3ae61591d8 100644 --- a/java/org/apache/catalina/util/StandardSessionIdGenerator.java +++ b/java/org/apache/catalina/util/StandardSessionIdGenerator.java @@ -32,9 +32,7 @@ public class StandardSessionIdGenerator extends SessionIdGeneratorBase { while (resultLenBytes < sessionIdLength) { getRandomBytes(random); - for (int j = 0; - j < random.length && resultLenBytes < sessionIdLength; - j++) { + for (int j = 0; j < random.length && resultLenBytes < sessionIdLength; j++) { byte b1 = (byte) ((random[j] & 0xf0) >> 4); byte b2 = (byte) (random[j] & 0x0f); if (b1 < 10) { diff --git a/java/org/apache/catalina/util/Strftime.java b/java/org/apache/catalina/util/Strftime.java index e54d2a6b64..23eef8811e 100644 --- a/java/org/apache/catalina/util/Strftime.java +++ b/java/org/apache/catalina/util/Strftime.java @@ -23,19 +23,17 @@ import java.util.Properties; import java.util.TimeZone; /** - * Converts dates to strings using the same format specifiers as strftime - * - * Note: This does not mimic strftime perfectly. Certain strftime commands, - * are not supported, and will convert as if they were literals. - * - * Certain complicated commands, like those dealing with the week of the year - * probably don't have exactly the same behavior as strftime. - * - * These limitations are due to use SimpleDateTime. If the conversion was done - * manually, all these limitations could be eliminated. - * - * The interface looks like a subset of DateFormat. Maybe someday someone will make this class - * extend DateFormat. + * Converts dates to strings using the same format specifiers as strftime Notes: + * <ul> + * <li>This does not mimic strftime perfectly. Certain strftime commands, are not supported, and will convert as if they + * were literals.</li> + * <li>Certain complicated commands, like those dealing with the week of the year probably don't have exactly the same + * behavior as strftime.</li> + * <li>These limitations are due to use SimpleDateTime. If the conversion was done manually, all these limitations could + * be eliminated.</li> + * <li>The interface looks like a subset of DateFormat. Maybe someday someone will make this class extend + * DateFormat.</li> + * </ul> * * @author Bip Thelin * @author Dan Sandberg @@ -49,59 +47,59 @@ public class Strftime { */ static { translate = new Properties(); - translate.put("a","EEE"); - translate.put("A","EEEE"); - translate.put("b","MMM"); - translate.put("B","MMMM"); - translate.put("c","EEE MMM d HH:mm:ss yyyy"); - - //There's no way to specify the century in SimpleDateFormat. We don't want to hard-code - //20 since this could be wrong for the pre-2000 files. - //translate.put("C", "20"); - translate.put("d","dd"); - translate.put("D","MM/dd/yy"); - translate.put("e","dd"); //will show as '03' instead of ' 3' - translate.put("F","yyyy-MM-dd"); - translate.put("g","yy"); - translate.put("G","yyyy"); - translate.put("H","HH"); - translate.put("h","MMM"); - translate.put("I","hh"); - translate.put("j","DDD"); - translate.put("k","HH"); //will show as '07' instead of ' 7' - translate.put("l","hh"); //will show as '07' instead of ' 7' - translate.put("m","MM"); - translate.put("M","mm"); - translate.put("n","\n"); - translate.put("p","a"); - translate.put("P","a"); //will show as pm instead of PM - translate.put("r","hh:mm:ss a"); - translate.put("R","HH:mm"); - //There's no way to specify this with SimpleDateFormat - //translate.put("s","seconds since epoch"); - translate.put("S","ss"); - translate.put("t","\t"); - translate.put("T","HH:mm:ss"); - //There's no way to specify this with SimpleDateFormat - //translate.put("u","day of week ( 1-7 )"); - - //There's no way to specify this with SimpleDateFormat - //translate.put("U","week in year with first Sunday as first day..."); - - translate.put("V","ww"); //I'm not sure this is always exactly the same - - //There's no way to specify this with SimpleDateFormat - //translate.put("W","week in year with first Monday as first day..."); - - //There's no way to specify this with SimpleDateFormat - //translate.put("w","E"); - translate.put("X","HH:mm:ss"); - translate.put("x","MM/dd/yy"); - translate.put("y","yy"); - translate.put("Y","yyyy"); - translate.put("Z","z"); - translate.put("z","Z"); - translate.put("%","%"); + translate.put("a", "EEE"); + translate.put("A", "EEEE"); + translate.put("b", "MMM"); + translate.put("B", "MMMM"); + translate.put("c", "EEE MMM d HH:mm:ss yyyy"); + + // There's no way to specify the century in SimpleDateFormat. We don't want to hard-code + // 20 since this could be wrong for the pre-2000 files. + // translate.put("C", "20"); + translate.put("d", "dd"); + translate.put("D", "MM/dd/yy"); + translate.put("e", "dd"); // will show as '03' instead of ' 3' + translate.put("F", "yyyy-MM-dd"); + translate.put("g", "yy"); + translate.put("G", "yyyy"); + translate.put("H", "HH"); + translate.put("h", "MMM"); + translate.put("I", "hh"); + translate.put("j", "DDD"); + translate.put("k", "HH"); // will show as '07' instead of ' 7' + translate.put("l", "hh"); // will show as '07' instead of ' 7' + translate.put("m", "MM"); + translate.put("M", "mm"); + translate.put("n", "\n"); + translate.put("p", "a"); + translate.put("P", "a"); // will show as pm instead of PM + translate.put("r", "hh:mm:ss a"); + translate.put("R", "HH:mm"); + // There's no way to specify this with SimpleDateFormat + // translate.put("s","seconds since epoch"); + translate.put("S", "ss"); + translate.put("t", "\t"); + translate.put("T", "HH:mm:ss"); + // There's no way to specify this with SimpleDateFormat + // translate.put("u","day of week ( 1-7 )"); + + // There's no way to specify this with SimpleDateFormat + // translate.put("U","week in year with first Sunday as first day..."); + + translate.put("V", "ww"); // I'm not sure this is always exactly the same + + // There's no way to specify this with SimpleDateFormat + // translate.put("W","week in year with first Monday as first day..."); + + // There's no way to specify this with SimpleDateFormat + // translate.put("w","E"); + translate.put("X", "HH:mm:ss"); + translate.put("x", "MM/dd/yy"); + translate.put("y", "yy"); + translate.put("Y", "yyyy"); + translate.put("Z", "z"); + translate.put("z", "Z"); + translate.put("%", "%"); } @@ -109,21 +107,22 @@ public class Strftime { * Create an instance of this date formatting class * * @param origFormat the strftime-style formatting string - * @param locale the locale to use for locale-specific conversions + * @param locale the locale to use for locale-specific conversions */ - public Strftime( String origFormat, Locale locale ) { - String convertedFormat = convertDateFormat( origFormat ); - simpleDateFormat = new SimpleDateFormat( convertedFormat, locale ); + public Strftime(String origFormat, Locale locale) { + String convertedFormat = convertDateFormat(origFormat); + simpleDateFormat = new SimpleDateFormat(convertedFormat, locale); } /** * Format the date according to the strftime-style string given in the constructor. * * @param date the date to format + * * @return the formatted date */ - public String format( Date date ) { - return simpleDateFormat.format( date ); + public String format(Date date) { + return simpleDateFormat.format(date); } /** @@ -139,50 +138,51 @@ public class Strftime { * Change the timezone used to format dates * * @param timeZone The new time zone + * * @see SimpleDateFormat#setTimeZone */ - public void setTimeZone( TimeZone timeZone ) { - simpleDateFormat.setTimeZone( timeZone ); + public void setTimeZone(TimeZone timeZone) { + simpleDateFormat.setTimeZone(timeZone); } /** - * Search the provided pattern and get the C standard - * Date/Time formatting rules and convert them to the - * Java equivalent. + * Search the provided pattern and get the C standard Date/Time formatting rules and convert them to the Java + * equivalent. * * @param pattern The pattern to search + * * @return The modified pattern */ - protected String convertDateFormat( String pattern ) { + protected String convertDateFormat(String pattern) { boolean inside = false; boolean mark = false; boolean modifiedCommand = false; StringBuilder buf = new StringBuilder(); - for(int i = 0; i < pattern.length(); i++) { + for (int i = 0; i < pattern.length(); i++) { char c = pattern.charAt(i); - if ( c=='%' && !mark ) { - mark=true; + if (c == '%' && !mark) { + mark = true; } else { - if ( mark ) { - if ( modifiedCommand ) { - //don't do anything--we just wanted to skip a char + if (mark) { + if (modifiedCommand) { + // don't do anything--we just wanted to skip a char modifiedCommand = false; mark = false; } else { - inside = translateCommand( buf, pattern, i, inside ); - //It's a modifier code - if ( c=='O' || c=='E' ) { + inside = translateCommand(buf, pattern, i, inside); + // It's a modifier code + if (c == 'O' || c == 'E') { modifiedCommand = true; } else { - mark=false; + mark = false; } } } else { - if ( !inside && c != ' ' ) { - //We start a literal, which we need to quote + if (!inside && c != ' ') { + // We start a literal, which we need to quote buf.append('\''); inside = true; } @@ -192,58 +192,58 @@ public class Strftime { } } - if ( buf.length() > 0 ) { - char lastChar = buf.charAt( buf.length() - 1 ); + if (buf.length() > 0) { + char lastChar = buf.charAt(buf.length() - 1); - if( lastChar!='\'' && inside ) { + if (lastChar != '\'' && inside) { buf.append('\''); } } return buf.toString(); } - protected String quote( String str, boolean insideQuotes ) { + protected String quote(String str, boolean insideQuotes) { String retVal = str; - if ( !insideQuotes ) { + if (!insideQuotes) { retVal = '\'' + retVal + '\''; } return retVal; } /** - * Try to get the Java Date/Time formatting associated with - * the C standard provided. + * Try to get the Java Date/Time formatting associated with the C standard provided. * - * @param buf The buffer - * @param pattern The date/time pattern - * @param index The char index + * @param buf The buffer + * @param pattern The date/time pattern + * @param index The char index * @param oldInside Flag value + * * @return True if new is inside buffer */ - protected boolean translateCommand( StringBuilder buf, String pattern, int index, boolean oldInside ) { - char firstChar = pattern.charAt( index ); + protected boolean translateCommand(StringBuilder buf, String pattern, int index, boolean oldInside) { + char firstChar = pattern.charAt(index); boolean newInside = oldInside; - //O and E are modifiers, they mean to present an alternative representation of the next char - //we just handle the next char as if the O or E wasn't there - if ( firstChar == 'O' || firstChar == 'E' ) { - if ( index + 1 < pattern.length() ) { - newInside = translateCommand( buf, pattern, index + 1, oldInside ); + // O and E are modifiers, they mean to present an alternative representation of the next char + // we just handle the next char as if the O or E wasn't there + if (firstChar == 'O' || firstChar == 'E') { + if (index + 1 < pattern.length()) { + newInside = translateCommand(buf, pattern, index + 1, oldInside); } else { - buf.append( quote("%" + firstChar, oldInside ) ); + buf.append(quote("%" + firstChar, oldInside)); } } else { - String command = translate.getProperty( String.valueOf( firstChar ) ); + String command = translate.getProperty(String.valueOf(firstChar)); - //If we don't find a format, treat it as a literal--That's what apache does - if ( command == null ) { - buf.append( quote( "%" + firstChar, oldInside ) ); + // If we don't find a format, treat it as a literal--That's what apache does + if (command == null) { + buf.append(quote("%" + firstChar, oldInside)); } else { - //If we were inside quotes, close the quotes - if ( oldInside ) { - buf.append( '\'' ); + // If we were inside quotes, close the quotes + if (oldInside) { + buf.append('\''); } - buf.append( command ); + buf.append(command); newInside = false; } } diff --git a/java/org/apache/catalina/util/StringUtil.java b/java/org/apache/catalina/util/StringUtil.java index 41062af232..8e6af25dc2 100644 --- a/java/org/apache/catalina/util/StringUtil.java +++ b/java/org/apache/catalina/util/StringUtil.java @@ -25,19 +25,15 @@ public class StringUtil { private static final Pattern commaSeparatedValuesPattern = Pattern.compile("\\s*,\\s*"); /** - * Splits a comma-separated string into an array of String values. - * - * Whitespace around the commas is removed. - * - * Null or empty values will return a zero-element array. + * Splits a comma-separated string into an array of String values. Whitespace around the commas is removed. Null or + * empty values will return a zero-element array. * * @param s The string to split by commas. * * @return An array of String values. */ public static String[] splitCommaSeparated(String s) { - return (s == null || s.length() == 0) ? new String[0] : - commaSeparatedValuesPattern.split(s); + return (s == null || s.length() == 0) ? new String[0] : commaSeparatedValuesPattern.split(s); } } \ No newline at end of file diff --git a/java/org/apache/catalina/util/TLSUtil.java b/java/org/apache/catalina/util/TLSUtil.java index 7f895ddb8f..dcec6dca63 100644 --- a/java/org/apache/catalina/util/TLSUtil.java +++ b/java/org/apache/catalina/util/TLSUtil.java @@ -22,15 +22,13 @@ import org.apache.tomcat.util.net.SSLSupport; public class TLSUtil { /** - * Determines if the named request attribute is used to pass information - * about the TLS configuration of the connection to the application. Both - * the standard request attributes defined by the Servlet specification and + * Determines if the named request attribute is used to pass information about the TLS configuration of the + * connection to the application. Both the standard request attributes defined by the Servlet specification and * Tomcat specific attributes are supported. * - * @param name The attribute name to test + * @param name The attribute name to test * - * @return {@code true} if the attribute is used to pass TLS configuration - * information, otherwise {@code false} + * @return {@code true} if the attribute is used to pass TLS configuration information, otherwise {@code false} */ public static boolean isTLSRequestAttribute(String name) { switch (name) { diff --git a/java/org/apache/catalina/util/TimeBucketCounter.java b/java/org/apache/catalina/util/TimeBucketCounter.java index e106e24e76..3b4726f7ff 100644 --- a/java/org/apache/catalina/util/TimeBucketCounter.java +++ b/java/org/apache/catalina/util/TimeBucketCounter.java @@ -64,7 +64,7 @@ public class TimeBucketCounter { /** * Creates a new TimeBucketCounter with the specified lifetime. * - * @param bucketDuration duration in seconds, e.g. for 1 minute pass 60 + * @param bucketDuration duration in seconds, e.g. for 1 minute pass 60 * @param executorService the executor service which will be used to run the maintenance */ public TimeBucketCounter(int bucketDuration, ScheduledExecutorService executorService) { @@ -89,8 +89,7 @@ public class TimeBucketCounter { // Start our thread if (sleeptime > 0) { - monitorFuture = executorService - .scheduleWithFixedDelay(new MaintenanceMonitor(), 0, 60, TimeUnit.SECONDS); + monitorFuture = executorService.scheduleWithFixedDelay(new MaintenanceMonitor(), 0, 60, TimeUnit.SECONDS); } } @@ -202,8 +201,7 @@ public class TimeBucketCounter { private class MaintenanceMonitor implements Runnable { @Override public void run() { - if (sleeptime > 0 && - (maintenanceFuture == null || maintenanceFuture.isDone())) { + if (sleeptime > 0 && (maintenanceFuture == null || maintenanceFuture.isDone())) { if (maintenanceFuture != null && maintenanceFuture.isDone()) { // There was an error executing the scheduled task, get it and log it try { diff --git a/java/org/apache/catalina/util/ToStringUtil.java b/java/org/apache/catalina/util/ToStringUtil.java index d1602bf423..4ba530f5ba 100644 --- a/java/org/apache/catalina/util/ToStringUtil.java +++ b/java/org/apache/catalina/util/ToStringUtil.java @@ -21,8 +21,7 @@ import org.apache.catalina.Container; import org.apache.catalina.Manager; /** - * Utility class used to help generate return values for calls to - * {@link Object#toString()}. + * Utility class used to help generate return values for calls to {@link Object#toString()}. */ public class ToStringUtil { @@ -46,8 +45,7 @@ public class ToStringUtil { } - private static String containedToString(Object contained, Object container, - String containerTypeName) { + private static String containedToString(Object contained, Object container, String containerTypeName) { StringBuilder sb = new StringBuilder(contained.getClass().getSimpleName()); sb.append('['); if (container == null) { diff --git a/java/org/apache/catalina/util/TomcatCSS.java b/java/org/apache/catalina/util/TomcatCSS.java index 21ffbcbe18..5f66d66396 100644 --- a/java/org/apache/catalina/util/TomcatCSS.java +++ b/java/org/apache/catalina/util/TomcatCSS.java @@ -19,14 +19,9 @@ package org.apache.catalina.util; public class TomcatCSS { - public static final String TOMCAT_CSS = - "body {font-family:Tahoma,Arial,sans-serif;} " + - "h1, h2, h3, b {color:white;background-color:#525D76;} " + - "h1 {font-size:22px;} " + - "h2 {font-size:16px;} " + - "h3 {font-size:14px;} " + - "p {font-size:12px;} " + - "a {color:black;} " + - ".line {height:1px;background-color:#525D76;border:none;}"; + public static final String TOMCAT_CSS = "body {font-family:Tahoma,Arial,sans-serif;} " + + "h1, h2, h3, b {color:white;background-color:#525D76;} " + "h1 {font-size:22px;} " + + "h2 {font-size:16px;} " + "h3 {font-size:14px;} " + "p {font-size:12px;} " + "a {color:black;} " + + ".line {height:1px;background-color:#525D76;border:none;}"; } diff --git a/java/org/apache/catalina/util/URLEncoder.java b/java/org/apache/catalina/util/URLEncoder.java index 2ac1d66a66..776c0a48e9 100644 --- a/java/org/apache/catalina/util/URLEncoder.java +++ b/java/org/apache/catalina/util/URLEncoder.java @@ -23,12 +23,9 @@ import java.nio.charset.Charset; import java.util.BitSet; /** - * This class is very similar to the java.net.URLEncoder class. - * - * Unfortunately, with java.net.URLEncoder there is no way to specify to the - * java.net.URLEncoder which characters should NOT be encoded. - * - * This code was moved from DefaultServlet.java + * This class is very similar to the java.net.URLEncoder class. Unfortunately, with java.net.URLEncoder there is no way + * to specify to the java.net.URLEncoder which characters should NOT be encoded. This code was moved from + * DefaultServlet.java * * @author Craig R. McClanahan * @author Remy Maucherat @@ -36,7 +33,7 @@ import java.util.BitSet; public final class URLEncoder implements Cloneable { private static final char[] hexadecimal = - {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static final URLEncoder DEFAULT = new URLEncoder(); public static final URLEncoder QUERY = new URLEncoder(); @@ -47,10 +44,9 @@ public final class URLEncoder implements Cloneable { * * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" * - * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" * - * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" - * / "*" / "+" / "," / ";" / "=" + * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" */ // ALPHA and DIGIT are always treated as safe characters // Add the remaining unreserved characters @@ -79,11 +75,13 @@ public final class URLEncoder implements Cloneable { /* * Encoder for query strings * https://www.w3.org/TR/html5/forms.html#application/x-www-form-urlencoded-encoding-algorithm + * // @formatter:off * 0x20 ' ' -> '+' * 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, 0x5F, 0x61 to 0x7A as-is * '*', '-', '.', '0' to '9', 'A' to 'Z', '_', 'a' to 'z' * Also '=' and '&' are not encoded * Everything else %nn encoded + * // @formatter:on */ // Special encoding for space QUERY.setEncodeSpaceAsPlus(true); @@ -97,7 +95,7 @@ public final class URLEncoder implements Cloneable { QUERY.addSafeCharacter('&'); } - //Array containing the safe characters set. + // Array containing the safe characters set. private final BitSet safeCharacters; private boolean encodeSpaceAsPlus = false; @@ -141,8 +139,8 @@ public final class URLEncoder implements Cloneable { /** * URL encodes the provided path using the given character set. * - * @param path The path to encode - * @param charset The character set to use to convert the path to bytes + * @param path The path to encode + * @param charset The character set to use to convert the path to bytes * * @return The encoded path */ @@ -156,15 +154,15 @@ public final class URLEncoder implements Cloneable { for (int i = 0; i < path.length(); i++) { int c = path.charAt(i); if (safeCharacters.get(c)) { - rewrittenPath.append((char)c); + rewrittenPath.append((char) c); } else if (encodeSpaceAsPlus && c == ' ') { rewrittenPath.append('+'); } else { // convert to external encoding before hex conversion try { - writer.write((char)c); + writer.write((char) c); writer.flush(); - } catch(IOException e) { + } catch (IOException e) { buf.reset(); continue; } diff --git a/java/org/apache/catalina/util/XMLWriter.java b/java/org/apache/catalina/util/XMLWriter.java index 143c305f34..a8789bbe84 100644 --- a/java/org/apache/catalina/util/XMLWriter.java +++ b/java/org/apache/catalina/util/XMLWriter.java @@ -74,8 +74,7 @@ public class XMLWriter { /** - * New XML writer utility that will store its data in an internal buffer - * and can write it to the specified writer. + * New XML writer utility that will store its data in an internal buffer and can write it to the specified writer. * <p> * See {@link #sendData()} * @@ -103,8 +102,8 @@ public class XMLWriter { * Write property to the XML. * * @param namespace Namespace - * @param name Property name - * @param value Property value + * @param name Property name + * @param value Property value */ public void writeProperty(String namespace, String name, String value) { writeElement(namespace, name, OPENING); @@ -116,9 +115,9 @@ public class XMLWriter { /** * Write an element. * - * @param name Element name + * @param name Element name * @param namespace Namespace abbreviation - * @param type Element type + * @param type Element type */ public void writeElement(String namespace, String name, int type) { writeElement(namespace, null, name, type); @@ -128,68 +127,65 @@ public class XMLWriter { /** * Write an element. * - * @param namespace Namespace abbreviation + * @param namespace Namespace abbreviation * @param namespaceInfo Namespace info - * @param name Element name - * @param type Element type + * @param name Element name + * @param type Element type */ - public void writeElement(String namespace, String namespaceInfo, - String name, int type) { + public void writeElement(String namespace, String namespaceInfo, String name, int type) { if ((namespace != null) && (namespace.length() > 0)) { switch (type) { - case OPENING: - if (lastWriteWasOpen) { - buffer.append('\n'); - } - if (namespaceInfo != null) { - buffer.append("<" + namespace + ":" + name + " xmlns:" - + namespace + "=\"" - + namespaceInfo + "\">"); - } else { - buffer.append("<" + namespace + ":" + name + ">"); - } - lastWriteWasOpen = true; - break; - case CLOSING: - buffer.append("</" + namespace + ":" + name + ">\n"); - lastWriteWasOpen = false; - break; - case NO_CONTENT: - default: - if (lastWriteWasOpen) { - buffer.append('\n'); - } - if (namespaceInfo != null) { - buffer.append("<" + namespace + ":" + name + " xmlns:" - + namespace + "=\"" - + namespaceInfo + "\"/>\n"); - } else { - buffer.append("<" + namespace + ":" + name + "/>\n"); - } - lastWriteWasOpen = false; - break; + case OPENING: + if (lastWriteWasOpen) { + buffer.append('\n'); + } + if (namespaceInfo != null) { + buffer.append( + "<" + namespace + ":" + name + " xmlns:" + namespace + "=\"" + namespaceInfo + "\">"); + } else { + buffer.append("<" + namespace + ":" + name + ">"); + } + lastWriteWasOpen = true; + break; + case CLOSING: + buffer.append("</" + namespace + ":" + name + ">\n"); + lastWriteWasOpen = false; + break; + case NO_CONTENT: + default: + if (lastWriteWasOpen) { + buffer.append('\n'); + } + if (namespaceInfo != null) { + buffer.append("<" + namespace + ":" + name + " xmlns:" + namespace + "=\"" + namespaceInfo + + "\"/>\n"); + } else { + buffer.append("<" + namespace + ":" + name + "/>\n"); + } + lastWriteWasOpen = false; + break; } } else { switch (type) { - case OPENING: - if (lastWriteWasOpen) { - buffer.append('\n'); - } - buffer.append("<" + name + ">"); - lastWriteWasOpen = true; - break; - case CLOSING: - buffer.append("</" + name + ">\n"); - lastWriteWasOpen = false; - break; - case NO_CONTENT: - default: - if (lastWriteWasOpen) { - buffer.append('\n'); - } - buffer.append("<" + name + "/>\n"); - lastWriteWasOpen = false; - break; + case OPENING: + if (lastWriteWasOpen) { + buffer.append('\n'); + } + buffer.append("<" + name + ">"); + lastWriteWasOpen = true; + break; + case CLOSING: + buffer.append("</" + name + ">\n"); + lastWriteWasOpen = false; + break; + case NO_CONTENT: + default: + if (lastWriteWasOpen) { + buffer.append('\n'); + } + buffer.append("<" + name + "/>\n"); + lastWriteWasOpen = false; + break; } } } @@ -235,10 +231,10 @@ public class XMLWriter { /** * Send data and reinitializes buffer, if a writer has been specified. + * * @throws IOException Error writing XML data */ - public void sendData() - throws IOException { + public void sendData() throws IOException { if (writer != null) { writer.write(buffer.toString()); buffer = new StringBuilder(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org