This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push: new 0121d3ffed jakarta.servlet cleanup 0121d3ffed is described below commit 0121d3ffed1999359664412b1e168304668a6e29 Author: remm <r...@apache.org> AuthorDate: Mon Mar 24 21:17:54 2025 +0100 jakarta.servlet cleanup --- java/jakarta/servlet/GenericFilter.java | 4 +- java/jakarta/servlet/GenericServlet.java | 2 + .../servlet/HttpMethodConstraintElement.java | 4 +- java/jakarta/servlet/MultipartConfigElement.java | 32 ++---- java/jakarta/servlet/Servlet.java | 2 +- java/jakarta/servlet/ServletConnection.java | 2 +- java/jakarta/servlet/ServletContext.java | 12 +- .../servlet/ServletContextAttributeEvent.java | 4 + java/jakarta/servlet/ServletContextEvent.java | 3 + java/jakarta/servlet/ServletException.java | 3 + java/jakarta/servlet/ServletRegistration.java | 4 +- java/jakarta/servlet/ServletRequest.java | 2 +- .../servlet/ServletRequestAttributeEvent.java | 4 + java/jakarta/servlet/ServletRequestEvent.java | 4 + java/jakarta/servlet/ServletResponse.java | 6 +- java/jakarta/servlet/ServletSecurityElement.java | 8 +- java/jakarta/servlet/SessionCookieConfig.java | 2 +- java/jakarta/servlet/UnavailableException.java | 3 + java/jakarta/servlet/WriteListener.java | 4 +- .../servlet/annotation/MultipartConfig.java | 3 +- .../descriptor/JspPropertyGroupDescriptor.java | 2 +- java/jakarta/servlet/http/Cookie.java | 15 ++- java/jakarta/servlet/http/HttpFilter.java | 2 + java/jakarta/servlet/http/HttpServlet.java | 125 +++++++++------------ java/jakarta/servlet/http/HttpServletRequest.java | 18 +-- java/jakarta/servlet/http/HttpServletResponse.java | 16 +-- java/jakarta/servlet/http/HttpSession.java | 8 +- .../servlet/http/HttpSessionBindingEvent.java | 3 + java/jakarta/servlet/http/HttpSessionEvent.java | 3 + java/jakarta/servlet/http/Part.java | 6 +- java/jakarta/servlet/jsp/JspException.java | 5 +- java/jakarta/servlet/jsp/JspTagException.java | 3 + java/jakarta/servlet/jsp/JspWriter.java | 10 +- java/jakarta/servlet/jsp/PageContext.java | 12 +- java/jakarta/servlet/jsp/SkipPageException.java | 3 + .../servlet/jsp/el/ImplicitObjectELResolver.java | 8 +- java/jakarta/servlet/jsp/el/ImportELResolver.java | 2 +- .../servlet/jsp/el/ScopedAttributeELResolver.java | 8 +- java/jakarta/servlet/jsp/tagext/BodyContent.java | 2 +- java/jakarta/servlet/jsp/tagext/BodyTag.java | 4 +- .../jakarta/servlet/jsp/tagext/BodyTagSupport.java | 5 +- .../servlet/jsp/tagext/SimpleTagSupport.java | 2 +- java/jakarta/servlet/jsp/tagext/Tag.java | 4 +- .../servlet/jsp/tagext/TagAttributeInfo.java | 20 ++-- java/jakarta/servlet/jsp/tagext/TagData.java | 2 +- java/jakarta/servlet/jsp/tagext/TagExtraInfo.java | 2 +- .../jakarta/servlet/jsp/tagext/TagLibraryInfo.java | 4 +- .../servlet/jsp/tagext/TagLibraryValidator.java | 4 +- java/jakarta/servlet/jsp/tagext/TagSupport.java | 12 +- java/jakarta/servlet/jsp/tagext/VariableInfo.java | 4 +- 50 files changed, 219 insertions(+), 203 deletions(-) diff --git a/java/jakarta/servlet/GenericFilter.java b/java/jakarta/servlet/GenericFilter.java index 3f2eb9d8f9..c7e5ed4969 100644 --- a/java/jakarta/servlet/GenericFilter.java +++ b/java/jakarta/servlet/GenericFilter.java @@ -16,6 +16,7 @@ */ package jakarta.servlet; +import java.io.Serial; import java.io.Serializable; import java.util.Enumeration; @@ -30,6 +31,7 @@ import java.util.Enumeration; */ public abstract class GenericFilter implements Filter, FilterConfig, Serializable { + @Serial private static final long serialVersionUID = 1L; /** @@ -74,7 +76,7 @@ public abstract class GenericFilter implements Filter, FilterConfig, Serializabl /** - * Convenience method for sub-classes to save them having to call <code>super.init(config)</code>. This is a NO-OP + * Convenience method for subclasses to save them having to call <code>super.init(config)</code>. This is a NO-OP * by default. * * @throws ServletException If an exception occurs that interrupts the Filter's normal operation diff --git a/java/jakarta/servlet/GenericServlet.java b/java/jakarta/servlet/GenericServlet.java index caf2ab3b88..589b8ba05d 100644 --- a/java/jakarta/servlet/GenericServlet.java +++ b/java/jakarta/servlet/GenericServlet.java @@ -17,6 +17,7 @@ package jakarta.servlet; import java.io.IOException; +import java.io.Serial; import java.util.Enumeration; /** @@ -36,6 +37,7 @@ import java.util.Enumeration; */ public abstract class GenericServlet implements Servlet, ServletConfig, java.io.Serializable { + @Serial private static final long serialVersionUID = 1L; private transient ServletConfig config; diff --git a/java/jakarta/servlet/HttpMethodConstraintElement.java b/java/jakarta/servlet/HttpMethodConstraintElement.java index d37c6a6cc8..37dc1a6edf 100644 --- a/java/jakarta/servlet/HttpMethodConstraintElement.java +++ b/java/jakarta/servlet/HttpMethodConstraintElement.java @@ -37,7 +37,7 @@ public class HttpMethodConstraintElement extends HttpConstraintElement { * @param methodName The HTTP method name */ public HttpMethodConstraintElement(String methodName) { - if (methodName == null || methodName.length() == 0) { + if (methodName == null || methodName.isEmpty()) { throw new IllegalArgumentException(lStrings.getString("httpMethodConstraintElement.invalidMethod")); } this.methodName = methodName; @@ -51,7 +51,7 @@ public class HttpMethodConstraintElement extends HttpConstraintElement { */ public HttpMethodConstraintElement(String methodName, HttpConstraintElement constraint) { super(constraint.getEmptyRoleSemantic(), constraint.getTransportGuarantee(), constraint.getRolesAllowed()); - if (methodName == null || methodName.length() == 0) { + if (methodName == null || methodName.isEmpty()) { throw new IllegalArgumentException(lStrings.getString("httpMethodConstraintElement.invalidMethod")); } this.methodName = methodName; diff --git a/java/jakarta/servlet/MultipartConfigElement.java b/java/jakarta/servlet/MultipartConfigElement.java index a91b30ad72..dce574a3da 100644 --- a/java/jakarta/servlet/MultipartConfigElement.java +++ b/java/jakarta/servlet/MultipartConfigElement.java @@ -16,10 +16,12 @@ */ package jakarta.servlet; +import java.util.Objects; + import jakarta.servlet.annotation.MultipartConfig; /** - * The programmatic equivalent of {@link jakarta.servlet.annotation.MultipartConfig} used to configure multi-part + * The programmatic equivalent of {@link jakarta.servlet.annotation.MultipartConfig} used to configure multipart * handling for a Servlet when registering a Servlet via code. * * @since Servlet 3.0 @@ -32,48 +34,36 @@ public class MultipartConfigElement { private final int fileSizeThreshold;// = 0; /** - * Create a programmatic multi-part configuration with a specific location and defaults for the remaining + * Create a programmatic multipart configuration with a specific location and defaults for the remaining * configuration elements. * * @param location The temporary location to store files */ public MultipartConfigElement(String location) { // Keep empty string default if location is null - if (location != null) { - this.location = location; - } else { - this.location = ""; - } + this.location = Objects.requireNonNullElse(location, ""); this.maxFileSize = -1; this.maxRequestSize = -1; this.fileSizeThreshold = 0; } /** - * Create a programmatic multi-part configuration from the individual configuration elements. + * Create a programmatic multipart configuration from the individual configuration elements. * * @param location The temporary location to store files * @param maxFileSize The maximum permitted size for a single file * @param maxRequestSize The maximum permitted size for a request - * @param fileSizeThreshold The size above which the file is save in the temporary location rather than retained in + * @param fileSizeThreshold The size above which the file is saved in the temporary location rather than retained in * memory. */ public MultipartConfigElement(String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold) { // Keep empty string default if location is null - if (location != null) { - this.location = location; - } else { - this.location = ""; - } + this.location = Objects.requireNonNullElse(location, ""); this.maxFileSize = maxFileSize; this.maxRequestSize = maxRequestSize; // Avoid threshold values of less than zero as they cause trigger NPEs // in the Commons FileUpload port for fields that have no data. - if (fileSizeThreshold > 0) { - this.fileSizeThreshold = fileSizeThreshold; - } else { - this.fileSizeThreshold = 0; - } + this.fileSizeThreshold = Math.max(fileSizeThreshold, 0); } /** @@ -116,9 +106,9 @@ public class MultipartConfigElement { } /** - * Obtain the size above which the file is save in the temporary location rather than retained in memory. + * Obtain the size above which the file is saved in the temporary location rather than retained in memory. * - * @return the size above which the file is save in the temporary location rather than retained in memory. + * @return the size above which the file is saved in the temporary location rather than retained in memory. */ public int getFileSizeThreshold() { return fileSizeThreshold; diff --git a/java/jakarta/servlet/Servlet.java b/java/jakarta/servlet/Servlet.java index 838b4f0d25..17551c9332 100644 --- a/java/jakarta/servlet/Servlet.java +++ b/java/jakarta/servlet/Servlet.java @@ -91,7 +91,7 @@ public interface Servlet { * Developers must be aware to synchronize access to any shared resources such as files, network connections, and as * well as the servlet's class and instance variables. More information on multithreaded programming in Java is * available in <a href="http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html"> the Java tutorial on - * multi-threaded programming</a>. + * multithreaded programming</a>. * * @param req the <code>ServletRequest</code> object that contains the client's request * @param res the <code>ServletResponse</code> object that contains the servlet's response diff --git a/java/jakarta/servlet/ServletConnection.java b/java/jakarta/servlet/ServletConnection.java index acdaee139d..559e0b0549 100644 --- a/java/jakarta/servlet/ServletConnection.java +++ b/java/jakarta/servlet/ServletConnection.java @@ -73,7 +73,7 @@ public interface ServletConnection { String getProtocolConnectionId(); /** - * Determine whether or not the incoming network connection to the server used encryption or not. Note that where a + * Determine whether the incoming network connection to the server used encryption or not. Note that where a * reverse proxy is used, the application may have a different view as to whether encryption is being used due to * the use of headers like {@code X-Forwarded-Proto}. * diff --git a/java/jakarta/servlet/ServletContext.java b/java/jakarta/servlet/ServletContext.java index 5054b3b796..9f38494ede 100644 --- a/java/jakarta/servlet/ServletContext.java +++ b/java/jakarta/servlet/ServletContext.java @@ -72,7 +72,7 @@ public interface ServletContext { * Returns a <code>ServletContext</code> object that corresponds to a specified URL on the server. * <p> * This method allows servlets to gain access to the context for various parts of the server, and as needed obtain - * {@link RequestDispatcher} objects from the context. The given path must be begin with "/", is interpreted + * {@link RequestDispatcher} objects from the context. The given path must begin with "/", is interpreted * relative to the server's document root and is matched against the context roots of other web applications hosted * on this container. * <p> @@ -270,7 +270,7 @@ public interface ServletContext { /** * Returns a <code>String</code> containing the real path for a given virtual path. For example, the path * "/index.html" returns the absolute file path on the server's filesystem would be served by a request for - * "http://host/contextPath/index.html", where contextPath is the context path of this ServletContext.. + * "http://host/contextPath/index.html", where contextPath is the context path of this ServletContext. * <p> * The real path returned will be in a form appropriate to the computer and operating system on which the servlet * container is running, including the proper path separators. This method returns <code>null</code> if the servlet @@ -301,7 +301,7 @@ public interface ServletContext { * <code>null</code> if the parameter does not exist. * <p> * This method can make available configuration information useful to an entire "web application". For example, it - * can provide a web site administrator's email address or the name of a system that holds critical data. + * can provide a website administrator's email address or the name of a system that holds critical data. * * @param name a <code>String</code> containing the name of the parameter whose value is requested * @@ -496,10 +496,10 @@ public interface ServletContext { ServletRegistration.Dynamic addJspFile(String jspName, String jspFile); /** - * Create an Servlet instance using the given class. The instance is just created. No initialisation occurs. + * Create a Servlet instance using the given class. The instance is just created. No initialisation occurs. * * @param <T> The type for the given class - * @param c The the class for which an instance should be created + * @param c The class for which an instance should be created * * @return The created Servlet instance. * @@ -626,7 +626,7 @@ public interface ServletContext { * Create a Filter instance using the given class. The instance is just created. No initialisation occurs. * * @param <T> The type for the given class - * @param c The the class for which an instance should be created + * @param c The class for which an instance should be created * * @return The created Filter instance. * diff --git a/java/jakarta/servlet/ServletContextAttributeEvent.java b/java/jakarta/servlet/ServletContextAttributeEvent.java index 61032652cf..cc30c72932 100644 --- a/java/jakarta/servlet/ServletContextAttributeEvent.java +++ b/java/jakarta/servlet/ServletContextAttributeEvent.java @@ -16,6 +16,8 @@ */ package jakarta.servlet; +import java.io.Serial; + /** * This is the event class for notifications about changes to the attributes of the servlet context of a web * application. @@ -25,6 +27,8 @@ package jakarta.servlet; * @since Servlet 2.3 */ public class ServletContextAttributeEvent extends ServletContextEvent { + + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/ServletContextEvent.java b/java/jakarta/servlet/ServletContextEvent.java index dc098b60a7..3366856a26 100644 --- a/java/jakarta/servlet/ServletContextEvent.java +++ b/java/jakarta/servlet/ServletContextEvent.java @@ -16,6 +16,8 @@ */ package jakarta.servlet; +import java.io.Serial; + /** * This is the event class for notifications about changes to the servlet context of a web application. * @@ -25,6 +27,7 @@ package jakarta.servlet; */ public class ServletContextEvent extends java.util.EventObject { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/ServletException.java b/java/jakarta/servlet/ServletException.java index ca8b5f10e8..8b18bad44a 100644 --- a/java/jakarta/servlet/ServletException.java +++ b/java/jakarta/servlet/ServletException.java @@ -16,11 +16,14 @@ */ package jakarta.servlet; +import java.io.Serial; + /** * Defines a general exception a servlet can throw when it encounters difficulty. */ public class ServletException extends Exception { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/ServletRegistration.java b/java/jakarta/servlet/ServletRegistration.java index c9b5385f8a..89ab1db8cc 100644 --- a/java/jakarta/servlet/ServletRegistration.java +++ b/java/jakarta/servlet/ServletRegistration.java @@ -31,7 +31,7 @@ public interface ServletRegistration extends Registration { * any of the specified URL patterns are already mapped to a different Servlet, no updates will be performed. If * this method is called multiple times, each successive call adds to the effects of the former. The returned set is * not backed by the ServletRegistration object, so changes in the returned set are not reflected in the - * ServletRegistration object, and vice-versa. + * ServletRegistration object, and vice versa. * * @param urlPatterns The URL patterns that this Servlet should be mapped to * @@ -82,7 +82,7 @@ public interface ServletRegistration extends Registration { Set<String> setServletSecurity(ServletSecurityElement constraint); /** - * Set the multi-part configuration for the associated Servlet. To clear the multi-part configuration specify + * Set the multipart configuration for the associated Servlet. To clear the multipart configuration specify * <code>null</code> as the new value. * * @param multipartConfig The configuration to associate with the Servlet diff --git a/java/jakarta/servlet/ServletRequest.java b/java/jakarta/servlet/ServletRequest.java index 1e700dd900..a38454f870 100644 --- a/java/jakarta/servlet/ServletRequest.java +++ b/java/jakarta/servlet/ServletRequest.java @@ -30,7 +30,7 @@ import java.util.Map; * <p> * A <code>ServletRequest</code> object provides data including parameter name and values, attributes, and an input * stream. Interfaces that extend <code>ServletRequest</code> can provide additional protocol-specific data (for - * example, HTTP data is provided by {@link jakarta.servlet.http.HttpServletRequest}. + * example, HTTP data is provided by {@link jakarta.servlet.http.HttpServletRequest}). * * @see jakarta.servlet.http.HttpServletRequest */ diff --git a/java/jakarta/servlet/ServletRequestAttributeEvent.java b/java/jakarta/servlet/ServletRequestAttributeEvent.java index d86563aa85..1ba9742d4d 100644 --- a/java/jakarta/servlet/ServletRequestAttributeEvent.java +++ b/java/jakarta/servlet/ServletRequestAttributeEvent.java @@ -16,6 +16,8 @@ */ package jakarta.servlet; +import java.io.Serial; + /** * This is the event class for notifications of changes to the attributes of the servlet request in an application. * @@ -24,6 +26,8 @@ package jakarta.servlet; * @since Servlet 2.4 */ public class ServletRequestAttributeEvent extends ServletRequestEvent { + + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/ServletRequestEvent.java b/java/jakarta/servlet/ServletRequestEvent.java index 6a24875365..5f40aa1c97 100644 --- a/java/jakarta/servlet/ServletRequestEvent.java +++ b/java/jakarta/servlet/ServletRequestEvent.java @@ -16,6 +16,8 @@ */ package jakarta.servlet; +import java.io.Serial; + /** * Events of this kind indicate lifecycle events for a ServletRequest. The source of the event is the ServletContext of * this web application. @@ -25,6 +27,8 @@ package jakarta.servlet; * @since Servlet 2.4 */ public class ServletRequestEvent extends java.util.EventObject { + + @Serial private static final long serialVersionUID = 1L; private final transient ServletRequest request; diff --git a/java/jakarta/servlet/ServletResponse.java b/java/jakarta/servlet/ServletResponse.java index 2935289882..869a3a6d71 100644 --- a/java/jakarta/servlet/ServletResponse.java +++ b/java/jakarta/servlet/ServletResponse.java @@ -66,7 +66,7 @@ public interface ServletResponse { * <code>getWriter</code> has been called or after the response has been committed have no effect on the character * encoding. If no character encoding has been specified, <code>ISO-8859-1</code> is returned. * <p> - * See RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt) for more information about character encoding and MIME. + * See <a href="http://www.ietf.org/rfc/rfc2047.txt">RFC 2047</a> for more information about character encoding and MIME. * * @return a <code>String</code> specifying the name of the character encoding, for example, <code>UTF-8</code> */ @@ -143,8 +143,8 @@ public interface ServletResponse { * via HTTP headers if the servlet does not specify a content type; however, it is still used to encode text written * via the servlet response's writer. * - * @param charset a String specifying only the character set defined by IANA Character Sets - * (http://www.iana.org/assignments/character-sets) + * @param charset a String specifying only the character set defined by + * <a href="http://www.iana.org/assignments/character-sets">IANA Character Sets</a> * * @see #setContentType #setLocale * @see #setCharacterEncoding(Charset) diff --git a/java/jakarta/servlet/ServletSecurityElement.java b/java/jakarta/servlet/ServletSecurityElement.java index 8c97fe116f..8d53d0bba8 100644 --- a/java/jakarta/servlet/ServletSecurityElement.java +++ b/java/jakarta/servlet/ServletSecurityElement.java @@ -27,7 +27,7 @@ import jakarta.servlet.annotation.HttpMethodConstraint; import jakarta.servlet.annotation.ServletSecurity; /** - * The programmatic equivalent of {@link jakarta.servlet.annotation.ServletSecurity} used to configre security + * The programmatic equivalent of {@link jakarta.servlet.annotation.ServletSecurity} used to configure security * constraints for a Servlet. * * @since Servlet 3.0 @@ -110,8 +110,7 @@ public class ServletSecurityElement extends HttpConstraintElement { * @return The security constraints for specific methods */ public Collection<HttpMethodConstraintElement> getHttpMethodConstraints() { - Collection<HttpMethodConstraintElement> result = new HashSet<>(methodConstraints.values()); - return result; + return new HashSet<>(methodConstraints.values()); } /** @@ -120,8 +119,7 @@ public class ServletSecurityElement extends HttpConstraintElement { * @return The names of the HTTP methods */ public Collection<String> getMethodNames() { - Collection<String> result = new HashSet<>(methodConstraints.keySet()); - return result; + return new HashSet<>(methodConstraints.keySet()); } private void addHttpMethodConstraints(Collection<HttpMethodConstraintElement> httpMethodConstraints) { diff --git a/java/jakarta/servlet/SessionCookieConfig.java b/java/jakarta/servlet/SessionCookieConfig.java index c9779052a9..d8d4a15b8e 100644 --- a/java/jakarta/servlet/SessionCookieConfig.java +++ b/java/jakarta/servlet/SessionCookieConfig.java @@ -162,7 +162,7 @@ public interface SessionCookieConfig { void setAttribute(String name, String value); /** - * Obtain the value for a sesison cookie given attribute. Values returned from this method must be consistent with + * Obtain the value for a session cookie given attribute. Values returned from this method must be consistent with * the values set and returned by the attribute specific getters and setters in this class. * * @param name Name of attribute to return diff --git a/java/jakarta/servlet/UnavailableException.java b/java/jakarta/servlet/UnavailableException.java index 3e3a433346..2d3701c565 100644 --- a/java/jakarta/servlet/UnavailableException.java +++ b/java/jakarta/servlet/UnavailableException.java @@ -16,6 +16,8 @@ */ package jakarta.servlet; +import java.io.Serial; + /** * Defines an exception that a servlet or filter throws to indicate that it is permanently or temporarily unavailable. * <p> @@ -34,6 +36,7 @@ package jakarta.servlet; */ public class UnavailableException extends ServletException { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/WriteListener.java b/java/jakarta/servlet/WriteListener.java index 8810012b72..3182388203 100644 --- a/java/jakarta/servlet/WriteListener.java +++ b/java/jakarta/servlet/WriteListener.java @@ -26,9 +26,9 @@ import java.io.IOException; public interface WriteListener extends java.util.EventListener { /** - * Invoked when it it possible to write data without blocking. The container will invoke this method the first time + * Invoked when it is possible to write data without blocking. The container will invoke this method the first time * for a request as soon as data can be written. Subsequent invocations will only occur if a call to - * {@link ServletOutputStream#isReady()} has returned false and it has since become possible to write data. + * {@link ServletOutputStream#isReady()} has returned false, and it has since become possible to write data. * * @throws IOException if an I/O error occurs while processing this event */ diff --git a/java/jakarta/servlet/annotation/MultipartConfig.java b/java/jakarta/servlet/annotation/MultipartConfig.java index 6e0d6926b9..0558b7dfd4 100644 --- a/java/jakarta/servlet/annotation/MultipartConfig.java +++ b/java/jakarta/servlet/annotation/MultipartConfig.java @@ -23,8 +23,7 @@ import java.lang.annotation.Target; /** * This annotation is used to indicate that the {@link jakarta.servlet.Servlet} on which it is declared expects requests - * to made using the {@code - * multipart/form-data} MIME type. <br> + * to be made using the {@code multipart/form-data} MIME type. <br> * <br> * {@link jakarta.servlet.http.Part} components of a given {@code * multipart/form-data} request are retrieved by a Servlet annotated with {@code MultipartConfig} by calling diff --git a/java/jakarta/servlet/descriptor/JspPropertyGroupDescriptor.java b/java/jakarta/servlet/descriptor/JspPropertyGroupDescriptor.java index 6cd415bebc..37fe44731b 100644 --- a/java/jakarta/servlet/descriptor/JspPropertyGroupDescriptor.java +++ b/java/jakarta/servlet/descriptor/JspPropertyGroupDescriptor.java @@ -113,7 +113,7 @@ public interface JspPropertyGroupDescriptor { /** * Should an error be raised at translation time for a page in this group if the page contains a reference (e.g. a - * tag) to a undeclared namespace. + * tag) to an undeclared namespace. * * @return {@code true} if an error should be raised, otherwise {@code false} */ diff --git a/java/jakarta/servlet/http/Cookie.java b/java/jakarta/servlet/http/Cookie.java index 8a659684d4..e217e58644 100644 --- a/java/jakarta/servlet/http/Cookie.java +++ b/java/jakarta/servlet/http/Cookie.java @@ -16,6 +16,7 @@ */ package jakarta.servlet.http; +import java.io.Serial; import java.io.Serializable; import java.text.MessageFormat; import java.util.BitSet; @@ -56,6 +57,7 @@ public class Cookie implements Cloneable, Serializable { private static final String EMPTY_STRING = ""; + @Serial private static final long serialVersionUID = 2L; /** @@ -414,7 +416,7 @@ public class Cookie implements Cloneable, Serializable { if (value == null) { return; } else { - // Case insensitive keys but retain case used + // Case-insensitive keys but retain case used attributes = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); } } @@ -500,13 +502,10 @@ public class Cookie implements Cloneable, Serializable { return false; } if (value == null) { - if (other.value != null) { - return false; - } - } else if (!value.equals(other.value)) { - return false; + return other.value == null; + } else { + return value.equals(other.value); } - return true; } } @@ -527,7 +526,7 @@ class CookieNameValidator { } void validate(String name) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException(lStrings.getString("err.cookie_name_blank")); } if (!isToken(name)) { diff --git a/java/jakarta/servlet/http/HttpFilter.java b/java/jakarta/servlet/http/HttpFilter.java index b02a306dbf..a4cbf8208a 100644 --- a/java/jakarta/servlet/http/HttpFilter.java +++ b/java/jakarta/servlet/http/HttpFilter.java @@ -17,6 +17,7 @@ package jakarta.servlet.http; import java.io.IOException; +import java.io.Serial; import jakarta.servlet.FilterChain; import jakarta.servlet.GenericFilter; @@ -30,6 +31,7 @@ import jakarta.servlet.ServletResponse; */ public abstract class HttpFilter extends GenericFilter { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/http/HttpServlet.java b/java/jakarta/servlet/http/HttpServlet.java index 354d51fd97..f135c11730 100644 --- a/java/jakarta/servlet/http/HttpServlet.java +++ b/java/jakarta/servlet/http/HttpServlet.java @@ -19,6 +19,7 @@ package jakarta.servlet.http; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Serial; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.lang.reflect.InvocationTargetException; @@ -43,7 +44,7 @@ import jakarta.servlet.WriteListener; /** - * Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of + * Provides an abstract class to be subclassed to create an HTTP servlet suitable for a website. A subclass of * <code>HttpServlet</code> must override at least one method, usually one of these: * <ul> * <li><code>doGet</code>, if the servlet supports HTTP GET requests @@ -68,6 +69,7 @@ import jakarta.servlet.WriteListener; */ public abstract class HttpServlet extends GenericServlet { + @Serial private static final long serialVersionUID = 1L; private static final String METHOD_DELETE = "DELETE"; @@ -362,7 +364,7 @@ public abstract class HttpServlet extends GenericServlet { String protocol = req.getProtocol(); // Note: Tomcat reports "" for HTTP/0.9 although some implementations // may report HTTP/0.9 - if (protocol.length() == 0 || protocol.endsWith("0.9") || protocol.endsWith("1.0")) { + if (protocol.isEmpty() || protocol.endsWith("0.9") || protocol.endsWith("1.0")) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); } else { resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg); @@ -505,7 +507,7 @@ public abstract class HttpServlet extends GenericServlet { // Tomcat specific hack to see if TRACE is allowed if (TomcatHack.getAllowTrace(req)) { - if (allow.length() == 0) { + if (allow.isEmpty()) { allow = METHOD_TRACE; } else { allow = allow + ", " + METHOD_TRACE; @@ -574,11 +576,11 @@ public abstract class HttpServlet extends GenericServlet { * <li>proxy-authorization</li> * </ul> * <p> - * Note that HTTP header names are case insensitive. + * Note that HTTP header names are case-insensitive. * * @param headerName the name of the HTTP request header to test * - * @return (@code true} if the HTTP request header is considered sensitive and should be excluded from the response + * @return {@code true} if the HTTP request header is considered sensitive and should be excluded from the response * to a {@code TRACE} request, otherwise {@code false} * * @since Servlet 6.1 @@ -611,66 +613,58 @@ public abstract class HttpServlet extends GenericServlet { String method = req.getMethod(); - if (method.equals(METHOD_GET)) { - long lastModified = getLastModified(req); - if (lastModified == -1) { - // servlet doesn't support if-modified-since, no reason - // to go through further expensive logic - doGet(req, resp); - } else { - long ifModifiedSince; - try { - ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE); - } catch (IllegalArgumentException iae) { - // Invalid date header - proceed as if none was set - ifModifiedSince = -1; - } - if (ifModifiedSince < (lastModified / 1000 * 1000)) { - // If the servlet mod time is later, call doGet() - // Round down to the nearest second for a proper compare - // A ifModifiedSince of -1 will always be less - maybeSetLastModified(resp, lastModified); + switch (method) { + case METHOD_GET -> { + long lastModified = getLastModified(req); + if (lastModified == -1) { + // servlet doesn't support if-modified-since, no reason + // to go through further expensive logic doGet(req, resp); } else { - resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED); + long ifModifiedSince; + try { + ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE); + } catch (IllegalArgumentException iae) { + // Invalid date header - proceed as if none was set + ifModifiedSince = -1; + } + if (ifModifiedSince < (lastModified / 1000 * 1000)) { + // If the servlet mod time is later, call doGet() + // Round down to the nearest second for a proper compare + // A ifModifiedSince of -1 will always be less + maybeSetLastModified(resp, lastModified); + doGet(req, resp); + } else { + resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED); + } } - } - - } else if (method.equals(METHOD_HEAD)) { - long lastModified = getLastModified(req); - maybeSetLastModified(resp, lastModified); - doHead(req, resp); - - } else if (method.equals(METHOD_POST)) { - doPost(req, resp); - - } else if (method.equals(METHOD_PUT)) { - doPut(req, resp); - - } else if (method.equals(METHOD_DELETE)) { - doDelete(req, resp); - - } else if (method.equals(METHOD_OPTIONS)) { - doOptions(req, resp); - } else if (method.equals(METHOD_TRACE)) { - doTrace(req, resp); - - } else if (method.equals(METHOD_PATCH)) { - doPatch(req, resp); - - } else { - // - // Note that this means NO servlet supports whatever - // method was requested, anywhere on this server. - // - - String errMsg = lStrings.getString("http.method_not_implemented"); - Object[] errArgs = new Object[1]; - errArgs[0] = method; - errMsg = MessageFormat.format(errMsg, errArgs); + } + case METHOD_HEAD -> { + long lastModified = getLastModified(req); + maybeSetLastModified(resp, lastModified); + doHead(req, resp); - resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, errMsg); + } + case METHOD_POST -> doPost(req, resp); + case METHOD_PUT -> doPut(req, resp); + case METHOD_DELETE -> doDelete(req, resp); + case METHOD_OPTIONS -> doOptions(req, resp); + case METHOD_TRACE -> doTrace(req, resp); + case METHOD_PATCH -> doPatch(req, resp); + default -> { + // + // Note that this means NO servlet supports whatever + // method was requested, anywhere on this server. + // + + String errMsg = lStrings.getString("http.method_not_implemented"); + Object[] errArgs = new Object[1]; + errArgs[0] = method; + errMsg = MessageFormat.format(errMsg, errArgs); + + resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, errMsg); + } } } @@ -878,7 +872,7 @@ public abstract class HttpServlet extends GenericServlet { } @Override - public void write(byte buf[], int offset, int len) throws IOException { + public void write(byte[] buf, int offset, int len) throws IOException { if (buf == null) { throw new NullPointerException(lStrings.getString("err.io.nullArray")); } @@ -1099,14 +1093,7 @@ public abstract class HttpServlet extends GenericServlet { /* * Calls NoBodyResponse.setContentLength() once the async request is complete. */ - private static class NoBodyAsyncContextListener implements AsyncListener { - - private final NoBodyResponse noBodyResponse; - - NoBodyAsyncContextListener(NoBodyResponse noBodyResponse) { - this.noBodyResponse = noBodyResponse; - } - + private record NoBodyAsyncContextListener(NoBodyResponse noBodyResponse) implements AsyncListener { @Override public void onComplete(AsyncEvent event) throws IOException { noBodyResponse.setContentLength(); diff --git a/java/jakarta/servlet/http/HttpServletRequest.java b/java/jakarta/servlet/http/HttpServletRequest.java index 277bc32fbc..daff471fb7 100644 --- a/java/jakarta/servlet/http/HttpServletRequest.java +++ b/java/jakarta/servlet/http/HttpServletRequest.java @@ -77,8 +77,8 @@ public interface HttpServletRequest extends ServletRequest { * <code>Date</code> object. Use this method with headers that contain dates, such as * <code>If-Modified-Since</code>. * <p> - * The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case - * insensitive. + * The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name + * is case-insensitive. * <p> * If the request did not have a header of the specified name, this method returns -1. If the header can't be * converted to a date, the method throws an <code>IllegalArgumentException</code>. @@ -95,7 +95,7 @@ public interface HttpServletRequest extends ServletRequest { /** * Returns the value of the specified request header as a <code>String</code>. If the request did not include a * header of the specified name, this method returns <code>null</code>. If there are multiple headers with the same - * name, this method returns the first head in the request. The header name is case insensitive. You can use this + * name, this method returns the first head in the request. The header name is case-insensitive. You can use this * method with any request header. * * @param name a <code>String</code> specifying the header name @@ -113,7 +113,7 @@ public interface HttpServletRequest extends ServletRequest { * different value rather than sending the header as a comma separated list. * <p> * If the request did not include any headers of the specified name, this method returns an empty - * <code>Enumeration</code>. The header name is case insensitive. You can use this method with any request header. + * <code>Enumeration</code>. The header name is case-insensitive. You can use this method with any request header. * * @param name a <code>String</code> specifying the header name * @@ -140,7 +140,7 @@ public interface HttpServletRequest extends ServletRequest { * of the specified name, this method returns -1. If the header cannot be converted to an integer, this method * throws a <code>NumberFormatException</code>. * <p> - * The header name is case insensitive. + * The header name is case-insensitive. * * @param name a <code>String</code> specifying the name of a request header * @@ -256,7 +256,7 @@ public interface HttpServletRequest extends ServletRequest { /** * Returns the login of the user making this request, if the user has been authenticated, or <code>null</code> if - * the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the + * the user has not been authenticated. Whether the username is sent with each subsequent request depends on the * browser and type of authentication. Same as the value of the CGI variable REMOTE_USER. * * @return a <code>String</code> specifying the login of the user making this request, or <code>null</code> if the @@ -446,14 +446,14 @@ public interface HttpServletRequest extends ServletRequest { boolean authenticate(HttpServletResponse response) throws IOException, ServletException; /** - * Authenticate the provided user name and password and then associated the authenticated user with the request. + * Authenticate the provided username and password and then associated the authenticated user with the request. * - * @param username The user name to authenticate + * @param username The username to authenticate * @param password The password to use to authenticate the user * * @throws ServletException If any of {@link #getRemoteUser()}, {@link #getUserPrincipal()} or * {@link #getAuthType()} are non-null, if the configured authenticator does not - * support user name and password authentication or if the authentication fails + * support username and password authentication or if the authentication fails * * @since Servlet 3.0 */ diff --git a/java/jakarta/servlet/http/HttpServletResponse.java b/java/jakarta/servlet/http/HttpServletResponse.java index 49be83c10a..13572e3a51 100644 --- a/java/jakarta/servlet/http/HttpServletResponse.java +++ b/java/jakarta/servlet/http/HttpServletResponse.java @@ -118,7 +118,7 @@ public interface HttpServletResponse extends ServletResponse { * <p> * This method has no effect if called from an include. * - * @param location the redirect location URL (may be absolute or relative) + * @param location the redirect location URL (can be absolute or relative) * * @exception IOException If an input or output exception occurs * @exception IllegalArgumentException If a relative URL is given and cannot be converted into an absolute URL @@ -137,7 +137,7 @@ public interface HttpServletResponse extends ServletResponse { * <p> * This method has no effect if called from an include. * - * @param location the redirect location URL (may be absolute or relative) + * @param location the redirect location URL (can be absolute or relative) * @param clearBuffer if {@code true}, clear the buffer and replace it with the data set by this method otherwise * retain the existing buffer * @@ -160,7 +160,7 @@ public interface HttpServletResponse extends ServletResponse { * <p> * This method has no effect if called from an include. * - * @param location the redirect location URL (may be absolute or relative) + * @param location the redirect location URL (can be absolute or relative) * @param sc the status code to use for the redirect * * @exception IOException If an input or output exception occurs @@ -199,7 +199,7 @@ public interface HttpServletResponse extends ServletResponse { * If the response has already been committed, this method throws an IllegalStateException. After using this method, * the response should be considered to be committed and should not be written to. * - * @param location the redirect location URL (may be absolute or relative) + * @param location the redirect location URL (can be absolute or relative) * @param sc the status code to use for the redirect * @param clearBuffer if {@code true}, clear the buffer and replace it with the data set by this method otherwise * retain the existing buffer @@ -242,8 +242,8 @@ public interface HttpServletResponse extends ServletResponse { * header before setting its value. * * @param name the name of the header - * @param value the header value If it contains octet string, it should be encoded according to RFC 2047 - * (http://www.ietf.org/rfc/rfc2047.txt) + * @param value the header value If it contains octet string, it should be encoded according to + * <a href="http://www.ietf.org/rfc/rfc2047.txt">RFC 2047</a> * * @see #containsHeader * @see #addHeader @@ -255,8 +255,8 @@ public interface HttpServletResponse extends ServletResponse { * values. * * @param name the name of the header - * @param value the additional header value If it contains octet string, it should be encoded according to RFC 2047 - * (http://www.ietf.org/rfc/rfc2047.txt) + * @param value the additional header value If it contains octet string, it should be encoded according to + * <a href="http://www.ietf.org/rfc/rfc2047.txt">RFC 2047</a> * * @see #setHeader */ diff --git a/java/jakarta/servlet/http/HttpSession.java b/java/jakarta/servlet/http/HttpSession.java index 963e4e4d97..1fbbd06425 100644 --- a/java/jakarta/servlet/http/HttpSession.java +++ b/java/jakarta/servlet/http/HttpSession.java @@ -22,7 +22,7 @@ import java.util.function.Consumer; import jakarta.servlet.ServletContext; /** - * Provides a way to identify a user across more than one page request or visit to a Web site and to store information + * Provides a way to identify a user across more than one page request or visit to a website and to store information * about that user. * <p> * The servlet container uses this interface to create a session between an HTTP client and an HTTP server. The session @@ -55,7 +55,7 @@ import jakarta.servlet.ServletContext; * <p> * This object is <b>only</b> valid within the scope of the HTTP request from which it was obtained. Once the processing * of that request returns to the container, this object must not be used. If there is a requirement to access the - * session outside of the scope of an HTTP request then this must be done via {@code #getAccessor()}. + * session outside the scope of an HTTP request then this must be done via {@code #getAccessor()}. * * @see HttpSessionBindingListener */ @@ -106,7 +106,7 @@ public interface HttpSession { /** * Specifies the time, in seconds, between client requests before the servlet container will invalidate this - * session. A zero or negative time indicates that the session should never timeout. + * session. A zero or negative time indicates that the session should never time out. * * @param interval An integer specifying the number of seconds */ @@ -116,7 +116,7 @@ public interface HttpSession { * Returns the maximum time interval, in seconds, that the servlet container will keep this session open between * client accesses. After this interval, the servlet container will invalidate the session. The maximum time * interval can be set with the <code>setMaxInactiveInterval</code> method. A zero or negative time indicates that - * the session should never timeout. + * the session should never time out. * * @return an integer specifying the number of seconds this session remains open between client requests * diff --git a/java/jakarta/servlet/http/HttpSessionBindingEvent.java b/java/jakarta/servlet/http/HttpSessionBindingEvent.java index 156a660625..4fa4cc51b0 100644 --- a/java/jakarta/servlet/http/HttpSessionBindingEvent.java +++ b/java/jakarta/servlet/http/HttpSessionBindingEvent.java @@ -16,6 +16,8 @@ */ package jakarta.servlet.http; +import java.io.Serial; + /** * Events of this type are either sent to an object that implements {@link HttpSessionBindingListener} when it is bound * or unbound from a session, or to an {@link HttpSessionAttributeListener} that has been configured in the deployment @@ -30,6 +32,7 @@ package jakarta.servlet.http; */ public class HttpSessionBindingEvent extends HttpSessionEvent { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/http/HttpSessionEvent.java b/java/jakarta/servlet/http/HttpSessionEvent.java index a61cd06c61..925ed5052b 100644 --- a/java/jakarta/servlet/http/HttpSessionEvent.java +++ b/java/jakarta/servlet/http/HttpSessionEvent.java @@ -16,12 +16,15 @@ */ package jakarta.servlet.http; +import java.io.Serial; + /** * This is the class representing event notifications for changes to sessions within a web application. * * @since Servlet 2.3 */ public class HttpSessionEvent extends java.util.EventObject { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/http/Part.java b/java/jakarta/servlet/http/Part.java index f60a259e25..92027e99f6 100644 --- a/java/jakarta/servlet/http/Part.java +++ b/java/jakarta/servlet/http/Part.java @@ -69,7 +69,7 @@ public interface Part { long getSize(); /** - * A convenience method to write an uploaded part to disk. The client code is not concerned with whether or not the + * A convenience method to write an uploaded part to disk. The client code is not concerned with whether the * part is stored in memory, or on disk in a temporary location. They just want to write the uploaded part to a * file. This method is not guaranteed to succeed if called more than once for the same part. This allows a * particular implementation to use, for example, file renaming, where possible, rather than copying all of the @@ -97,7 +97,7 @@ public interface Part { /** * Obtains the value of the specified part header as a String. If there are multiple headers with the same name, - * this method returns the first header in the part. The header name is case insensitive. + * this method returns the first header in the part. The header name is case-insensitive. * * @param name Header name * @@ -108,7 +108,7 @@ public interface Part { /** * Obtain all the values of the specified part header. * - * @param name The name of the header of interest. The header name is case insensitive. + * @param name The name of the header of interest. The header name is case-insensitive. * * @return All the values of the specified part header. If the part did not include any headers of the specified * name, this method returns an empty Collection. diff --git a/java/jakarta/servlet/jsp/JspException.java b/java/jakarta/servlet/jsp/JspException.java index f61eeb4dce..c60f43f227 100644 --- a/java/jakarta/servlet/jsp/JspException.java +++ b/java/jakarta/servlet/jsp/JspException.java @@ -16,12 +16,15 @@ */ package jakarta.servlet.jsp; +import java.io.Serial; + /** - * A generic exception known to the JSP engine; uncaught JspExceptions will result in an invocation of the errorpage + * A generic exception known to the JSP engine; uncaught JspExceptions will result in an invocation of the error page * machinery. */ public class JspException extends Exception { + @Serial private static final long serialVersionUID = 1L; diff --git a/java/jakarta/servlet/jsp/JspTagException.java b/java/jakarta/servlet/jsp/JspTagException.java index 9507c9ae89..ed5ae5f749 100644 --- a/java/jakarta/servlet/jsp/JspTagException.java +++ b/java/jakarta/servlet/jsp/JspTagException.java @@ -16,12 +16,15 @@ */ package jakarta.servlet.jsp; +import java.io.Serial; + /** * Exception to be used by a Tag Handler to indicate some unrecoverable error. This error is to be caught by the top * level of the JSP page and will result in an error page. */ public class JspTagException extends JspException { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/jsp/JspWriter.java b/java/jakarta/servlet/jsp/JspWriter.java index 227700fdce..0825d9f755 100644 --- a/java/jakarta/servlet/jsp/JspWriter.java +++ b/java/jakarta/servlet/jsp/JspWriter.java @@ -82,7 +82,7 @@ public abstract class JspWriter extends java.io.Writer { * Protected constructor. * * @param bufferSize the size of the buffer to be used by the JspWriter - * @param autoFlush whether the JspWriter should be autoflushing + * @param autoFlush whether the JspWriter should be auto flushing */ protected JspWriter(int bufferSize, boolean autoFlush) { this.bufferSize = bufferSize; @@ -179,7 +179,7 @@ public abstract class JspWriter extends java.io.Writer { * @throws NullPointerException If <code>s</code> is <code>null</code> * @throws IOException If an error occurred while writing */ - public abstract void print(char s[]) throws IOException; + public abstract void print(char[] s) throws IOException; /** * Print a string. If the argument is <code>null</code> then the string <code>"null"</code> is printed. Otherwise, @@ -285,7 +285,7 @@ public abstract class JspWriter extends java.io.Writer { * * @throws IOException If an error occurred while writing */ - public abstract void println(char x[]) throws IOException; + public abstract void println(char[] x) throws IOException; /** * Print a String and then terminate the line. This method behaves as though it invokes @@ -327,7 +327,7 @@ public abstract class JspWriter extends java.io.Writer { /** * Flush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them * immediately to their intended destination. Then, if that destination is another character or byte stream, flush - * it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. + * it. Thus, one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. * <p> * The method may be invoked indirectly if the buffer size is exceeded. * <p> @@ -386,7 +386,7 @@ public abstract class JspWriter extends java.io.Writer { protected int bufferSize; /** - * Whether the JspWriter is autoflushing. + * Whether the JspWriter is auto flushing. */ protected boolean autoFlush; } diff --git a/java/jakarta/servlet/jsp/PageContext.java b/java/jakarta/servlet/jsp/PageContext.java index 7a7df8d355..3b6dedbc64 100644 --- a/java/jakarta/servlet/jsp/PageContext.java +++ b/java/jakarta/servlet/jsp/PageContext.java @@ -53,7 +53,7 @@ import jakarta.servlet.jsp.tagext.BodyContent; * <li>a mechanism to manage session usage by the page * <li>a mechanism to expose page directive attributes to the scripting environment * <li>mechanisms to forward or include the current request to other active components in the application - * <li>a mechanism to handle errorpage exception processing + * <li>a mechanism to handle error page exception processing * </ul> * <p> * <B>Methods Intended for Container Generated Code</B> @@ -118,7 +118,7 @@ public abstract class PageContext extends JspContext { public static final String PAGE = "jakarta.servlet.jsp.jspPage"; /** - * Name used to store this PageContext in it's own name table. + * Name used to store this PageContext in its own name table. */ public static final String PAGECONTEXT = "jakarta.servlet.jsp.jspPageContext"; @@ -199,7 +199,7 @@ public abstract class PageContext extends JspContext { * the PageContext for potential reuse by a later invocation of initialize(). This method is typically called from * JspFactory.releasePageContext(). * <p> - * Subclasses shall envelope this method. + * Subclasses shall override this method. * <p> * This method should not be used by page or tag library authors. */ @@ -242,7 +242,7 @@ public abstract class PageContext extends JspContext { /** * The current value of the exception object (an Exception). * - * @return any exception passed to this as an errorpage + * @return any exception passed to this as an error page */ public abstract Exception getException(); @@ -301,7 +301,7 @@ public abstract class PageContext extends JspContext { * to the ServletResponse output stream. * </p> * <p> - * The current JspWriter "out" for this JSP is flushed as a side-effect of this call, prior to processing the + * The current JspWriter "out" for this JSP is flushed as a side effect of this call, prior to processing the * include. * </p> * <p> @@ -328,7 +328,7 @@ public abstract class PageContext extends JspContext { * to the current JspWriter returned by a call to getOut(). * </p> * <p> - * If flush is true, The current JspWriter "out" for this JSP is flushed as a side-effect of this call, prior to + * If flush is true, The current JspWriter "out" for this JSP is flushed as a side effect of this call, prior to * processing the include. Otherwise, the JspWriter "out" is not flushed. * </p> * <p> diff --git a/java/jakarta/servlet/jsp/SkipPageException.java b/java/jakarta/servlet/jsp/SkipPageException.java index f9926c3fea..c7cc167f52 100644 --- a/java/jakarta/servlet/jsp/SkipPageException.java +++ b/java/jakarta/servlet/jsp/SkipPageException.java @@ -16,6 +16,8 @@ */ package jakarta.servlet.jsp; +import java.io.Serial; + /** * Exception to indicate the calling page must cease evaluation. Thrown by a simple tag handler to indicate that the * remainder of the page must not be evaluated. The result is propagated back to the page in the case where one tag @@ -32,6 +34,7 @@ package jakarta.servlet.jsp; */ public class SkipPageException extends JspException { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/java/jakarta/servlet/jsp/el/ImplicitObjectELResolver.java b/java/jakarta/servlet/jsp/el/ImplicitObjectELResolver.java index dfee4f4dee..ebb791d68e 100644 --- a/java/jakarta/servlet/jsp/el/ImplicitObjectELResolver.java +++ b/java/jakarta/servlet/jsp/el/ImplicitObjectELResolver.java @@ -57,7 +57,7 @@ public class ImplicitObjectELResolver extends ELResolver { if (base == null && property != null) { Scope scope = Scope.lookupMap.get(property.toString()); if (scope != null) { - return scope.getScopeValue(context, base, property); + return scope.getScopeValue(context, null, property); } } return null; @@ -69,7 +69,7 @@ public class ImplicitObjectELResolver extends ELResolver { if (base == null && property != null) { if (Scope.lookupMap.containsKey(property.toString())) { - context.setPropertyResolved(base, property); + context.setPropertyResolved(null, property); } } return null; @@ -81,7 +81,7 @@ public class ImplicitObjectELResolver extends ELResolver { if (base == null && property != null) { if (Scope.lookupMap.containsKey(property.toString())) { - context.setPropertyResolved(base, property); + context.setPropertyResolved(null, property); throw new PropertyNotWritableException(); } } @@ -93,7 +93,7 @@ public class ImplicitObjectELResolver extends ELResolver { if (base == null && property != null) { if (Scope.lookupMap.containsKey(property.toString())) { - context.setPropertyResolved(base, property); + context.setPropertyResolved(null, property); return true; } } diff --git a/java/jakarta/servlet/jsp/el/ImportELResolver.java b/java/jakarta/servlet/jsp/el/ImportELResolver.java index 57a6c386ed..eb3746bbce 100644 --- a/java/jakarta/servlet/jsp/el/ImportELResolver.java +++ b/java/jakarta/servlet/jsp/el/ImportELResolver.java @@ -76,7 +76,7 @@ public class ImportELResolver extends ELResolver { ImportHandler importHandler = context.getImportHandler(); if (importHandler != null) { String key = property.toString(); - Class<?> clazz = null; + Class<?> clazz; if (resolveClass) { clazz = importHandler.resolveClass(key); if (clazz != null) { diff --git a/java/jakarta/servlet/jsp/el/ScopedAttributeELResolver.java b/java/jakarta/servlet/jsp/el/ScopedAttributeELResolver.java index a068791d02..da6ec74343 100644 --- a/java/jakarta/servlet/jsp/el/ScopedAttributeELResolver.java +++ b/java/jakarta/servlet/jsp/el/ScopedAttributeELResolver.java @@ -50,7 +50,7 @@ public class ScopedAttributeELResolver extends ELResolver { result = page.findAttribute(key); if (result != null) { - context.setPropertyResolved(base, property); + context.setPropertyResolved(null, property); } } } @@ -63,7 +63,7 @@ public class ScopedAttributeELResolver extends ELResolver { Objects.requireNonNull(context); if (base == null) { - context.setPropertyResolved(base, property); + context.setPropertyResolved(null, property); return Object.class; } @@ -75,7 +75,7 @@ public class ScopedAttributeELResolver extends ELResolver { Objects.requireNonNull(context); if (base == null) { - context.setPropertyResolved(base, property); + context.setPropertyResolved(null, property); if (property != null) { String key = property.toString(); PageContext page = (PageContext) context.getContext(JspContext.class); @@ -94,7 +94,7 @@ public class ScopedAttributeELResolver extends ELResolver { Objects.requireNonNull(context); if (base == null) { - context.setPropertyResolved(base, property); + context.setPropertyResolved(null, property); } return false; diff --git a/java/jakarta/servlet/jsp/tagext/BodyContent.java b/java/jakarta/servlet/jsp/tagext/BodyContent.java index 6858ddd35c..fccb0dec3a 100644 --- a/java/jakarta/servlet/jsp/tagext/BodyContent.java +++ b/java/jakarta/servlet/jsp/tagext/BodyContent.java @@ -44,7 +44,7 @@ import jakarta.servlet.jsp.JspWriter; public abstract class BodyContent extends JspWriter { /** - * Protected constructor. Unbounded buffer, no autoflushing. + * Protected constructor. Unbounded buffer, no auto flushing. * * @param e the enclosing JspWriter */ diff --git a/java/jakarta/servlet/jsp/tagext/BodyTag.java b/java/jakarta/servlet/jsp/tagext/BodyTag.java index 4f6141c54f..aa884b345f 100644 --- a/java/jakarta/servlet/jsp/tagext/BodyTag.java +++ b/java/jakarta/servlet/jsp/tagext/BodyTag.java @@ -63,7 +63,7 @@ import jakarta.servlet.jsp.JspException; * <p> * <B>Empty and Non-Empty Action</B> * <p> - * If the TagLibraryDescriptor file indicates that the action must always have an empty element body, by an + * If the TagLibraryDescriptor file indicates that the action must always have an empty element body, by a * <body-content> entry of "empty", then the doStartTag() method must return SKIP_BODY. Otherwise, the * doStartTag() method may return SKIP_BODY, EVAL_BODY_INCLUDE, or EVAL_BODY_BUFFERED. * <p> @@ -96,7 +96,7 @@ public interface BodyTag extends IterationTag { * or for non-empty tags whose doStartTag() method returns SKIP_BODY or EVAL_BODY_INCLUDE. * <p> * When setBodyContent is invoked, the value of the implicit object out has already been changed in the pageContext - * object. The BodyContent object passed will have not data on it but may have been reused (and cleared) from some + * object. The BodyContent object passed will have no data on it but may have been reused (and cleared) from some * previous invocation. * <p> * The BodyContent object is available and with the appropriate content until after the invocation of the doEndTag diff --git a/java/jakarta/servlet/jsp/tagext/BodyTagSupport.java b/java/jakarta/servlet/jsp/tagext/BodyTagSupport.java index ffb5909f95..e168c0fdf4 100644 --- a/java/jakarta/servlet/jsp/tagext/BodyTagSupport.java +++ b/java/jakarta/servlet/jsp/tagext/BodyTagSupport.java @@ -16,6 +16,8 @@ */ package jakarta.servlet.jsp.tagext; +import java.io.Serial; + import jakarta.servlet.jsp.JspException; import jakarta.servlet.jsp.JspWriter; @@ -29,6 +31,7 @@ import jakarta.servlet.jsp.JspWriter; */ public class BodyTagSupport extends TagSupport implements BodyTag { + @Serial private static final long serialVersionUID = -7235752615580319833L; /** @@ -98,7 +101,7 @@ public class BodyTagSupport extends TagSupport implements BodyTag { } /** - * After the body evaluation: do not reevaluate and continue with the page. By default nothing is done with the + * After the body evaluation: do not reevaluate and continue with the page. By default, nothing is done with the * bodyContent data (if any). * * @return SKIP_BODY diff --git a/java/jakarta/servlet/jsp/tagext/SimpleTagSupport.java b/java/jakarta/servlet/jsp/tagext/SimpleTagSupport.java index 3398b2d4f8..84a05c08a9 100644 --- a/java/jakarta/servlet/jsp/tagext/SimpleTagSupport.java +++ b/java/jakarta/servlet/jsp/tagext/SimpleTagSupport.java @@ -157,7 +157,7 @@ public class SimpleTagSupport implements SimpleTag { * * @return the nearest ancestor that implements the interface or is an instance of the class specified */ - public static final JspTag findAncestorWithClass(JspTag from, Class<?> klass) { + public static JspTag findAncestorWithClass(JspTag from, Class<?> klass) { boolean isInterface = false; if (from == null || klass == null || diff --git a/java/jakarta/servlet/jsp/tagext/Tag.java b/java/jakarta/servlet/jsp/tagext/Tag.java index 16314411f6..1d501763d6 100644 --- a/java/jakarta/servlet/jsp/tagext/Tag.java +++ b/java/jakarta/servlet/jsp/tagext/Tag.java @@ -70,7 +70,7 @@ import jakarta.servlet.jsp.PageContext; * <B>Empty and Non-Empty Action</B> * </p> * <p> - * If the TagLibraryDescriptor file indicates that the action must always have an empty action, by an + * If the TagLibraryDescriptor file indicates that the action must always have an empty action, by a * <body-content> entry of "empty", then the doStartTag() method must return SKIP_BODY. * </p> * <p> @@ -148,7 +148,7 @@ public interface Tag extends JspTag { * The current version of the specification only provides one formal way of indicating the observable type of a tag * handler: its tag handler implementation class, described in the tag-class sub-element of the tag element. This is * extended in an informal manner by allowing the tag library author to indicate in the description sub-element an - * observable type. The type should be a sub-type of the tag handler implementation class or void. This additional + * observable type. The type should be a subtype of the tag handler implementation class or void. This additional * constraint can be exploited by a specialized container that knows about that specific tag library, as in the case * of the JSP standard tag library. * diff --git a/java/jakarta/servlet/jsp/tagext/TagAttributeInfo.java b/java/jakarta/servlet/jsp/tagext/TagAttributeInfo.java index 92e9df69b8..54e1c86c3f 100644 --- a/java/jakarta/servlet/jsp/tagext/TagAttributeInfo.java +++ b/java/jakarta/servlet/jsp/tagext/TagAttributeInfo.java @@ -165,17 +165,15 @@ public class TagAttributeInfo { */ @Override public String toString() { - StringBuilder b = new StringBuilder(64); - b.append("name = " + name + " "); - b.append("type = " + type + " "); - b.append("reqTime = " + reqTime + " "); - b.append("required = " + required + " "); - b.append("fragment = " + fragment + " "); - b.append("deferredValue = " + deferredValue + " "); - b.append("expectedTypeName = " + expectedTypeName + " "); - b.append("deferredMethod = " + deferredMethod + " "); - b.append("methodSignature = " + methodSignature); - return b.toString(); + return "name = " + name + " " + + "type = " + type + " " + + "reqTime = " + reqTime + " " + + "required = " + required + " " + + "fragment = " + fragment + " " + + "deferredValue = " + deferredValue + " " + + "expectedTypeName = " + expectedTypeName + " " + + "deferredMethod = " + deferredMethod + " " + + "methodSignature = " + methodSignature; } /* diff --git a/java/jakarta/servlet/jsp/tagext/TagData.java b/java/jakarta/servlet/jsp/tagext/TagData.java index 30de13b281..9c9f6fff40 100644 --- a/java/jakarta/servlet/jsp/tagext/TagData.java +++ b/java/jakarta/servlet/jsp/tagext/TagData.java @@ -49,7 +49,7 @@ public class TagData implements Cloneable { * * @param atts the static attribute and values. May be null. */ - public TagData(Object[] atts[]) { + public TagData(Object[][] atts) { if (atts == null) { attributes = new Hashtable<>(); } else { diff --git a/java/jakarta/servlet/jsp/tagext/TagExtraInfo.java b/java/jakarta/servlet/jsp/tagext/TagExtraInfo.java index 7a6b60a893..12e3a8f98f 100644 --- a/java/jakarta/servlet/jsp/tagext/TagExtraInfo.java +++ b/java/jakarta/servlet/jsp/tagext/TagExtraInfo.java @@ -35,7 +35,7 @@ package jakarta.servlet.jsp.tagext; * being translated. The call should happen before any invocation on validate() and before any invocation on * getVariableInfo(). * <p> - * <b>NOTE:</b> It is a (translation time) error for a tag definition in a TLD with one or more variable subelements to + * <b>NOTE:</b> It is a (translation time) error for a tag definition in a TLD with one or more variable sub elements to * have an associated TagExtraInfo implementation that returns a VariableInfo array with one or more elements from a * call to getVariableInfo(). */ diff --git a/java/jakarta/servlet/jsp/tagext/TagLibraryInfo.java b/java/jakarta/servlet/jsp/tagext/TagLibraryInfo.java index a4f799f894..2d9a79eb8d 100644 --- a/java/jakarta/servlet/jsp/tagext/TagLibraryInfo.java +++ b/java/jakarta/servlet/jsp/tagext/TagLibraryInfo.java @@ -126,7 +126,7 @@ public abstract class TagLibraryInfo { * @return the TagInfo for the tag with the specified short name, or null if no such tag is found */ public TagInfo getTag(String shortname) { - TagInfo tags[] = getTags(); + TagInfo[] tags = getTags(); if (tags == null || tags.length == 0 || shortname == null) { return null; @@ -150,7 +150,7 @@ public abstract class TagLibraryInfo { * @since JSP 2.0 */ public TagFileInfo getTagFile(String shortname) { - TagFileInfo tagFiles[] = getTagFiles(); + TagFileInfo[] tagFiles = getTagFiles(); if (tagFiles == null || tagFiles.length == 0) { return null; diff --git a/java/jakarta/servlet/jsp/tagext/TagLibraryValidator.java b/java/jakarta/servlet/jsp/tagext/TagLibraryValidator.java index 478d9ee558..6981b49c15 100644 --- a/java/jakarta/servlet/jsp/tagext/TagLibraryValidator.java +++ b/java/jakarta/servlet/jsp/tagext/TagLibraryValidator.java @@ -16,8 +16,6 @@ */ package jakarta.servlet.jsp.tagext; -import java.util.Collections; -import java.util.HashMap; import java.util.Map; /** @@ -70,7 +68,7 @@ public abstract class TagLibraryValidator { * @param map A Map describing the init parameters */ public void setInitParameters(Map<String,Object> map) { - initParameters = Collections.unmodifiableMap(new HashMap<>(map)); + initParameters = Map.copyOf(map); } diff --git a/java/jakarta/servlet/jsp/tagext/TagSupport.java b/java/jakarta/servlet/jsp/tagext/TagSupport.java index 7fda1d03d2..48d554759b 100644 --- a/java/jakarta/servlet/jsp/tagext/TagSupport.java +++ b/java/jakarta/servlet/jsp/tagext/TagSupport.java @@ -16,6 +16,7 @@ */ package jakarta.servlet.jsp.tagext; +import java.io.Serial; import java.io.Serializable; import java.util.Collections; import java.util.Enumeration; @@ -37,6 +38,7 @@ import jakarta.servlet.jsp.PageContext; */ public class TagSupport implements IterationTag, Serializable { + @Serial private static final long serialVersionUID = 1L; /** @@ -44,8 +46,8 @@ public class TagSupport implements IterationTag, Serializable { * method from the Tag interface. This method is used for coordination among cooperating tags. * <p> * The current version of the specification only provides one formal way of indicating the observable type of a tag - * handler: its tag handler implementation class, described in the tag-class subelement of the tag element. This is - * extended in an informal manner by allowing the tag library author to indicate in the description subelement an + * handler: its tag handler implementation class, described in the tag-class sub element of the tag element. This is + * extended in an informal manner by allowing the tag library author to indicate in the description sub element an * observable type. The type should be a subtype of the tag handler implementation class or void. This additional * constraint can be exploited by a specialized container that knows about that specific tag library, as in the case * of the JSP standard tag library. @@ -59,7 +61,7 @@ public class TagSupport implements IterationTag, Serializable { * * @return the nearest ancestor that implements the interface or is an instance of the class specified */ - public static final Tag findAncestorWithClass(Tag from, Class<?> klass) { + public static Tag findAncestorWithClass(Tag from, Class<?> klass) { boolean isInterface = false; if (from == null || klass == null || @@ -74,7 +76,7 @@ public class TagSupport implements IterationTag, Serializable { return null; } - if ((isInterface && klass.isInstance(tag)) || ((Class<?>) klass).isAssignableFrom(tag.getClass())) { + if ((isInterface && klass.isInstance(tag)) || klass.isAssignableFrom(tag.getClass())) { return tag; } from = tag; @@ -218,7 +220,7 @@ public class TagSupport implements IterationTag, Serializable { } /** - * Get a the value associated with a key. + * Get the value associated with a key. * * @param k The string key. * diff --git a/java/jakarta/servlet/jsp/tagext/VariableInfo.java b/java/jakarta/servlet/jsp/tagext/VariableInfo.java index e3409ec51c..ec6c507809 100644 --- a/java/jakarta/servlet/jsp/tagext/VariableInfo.java +++ b/java/jakarta/servlet/jsp/tagext/VariableInfo.java @@ -18,7 +18,7 @@ package jakarta.servlet.jsp.tagext; /** * Information on the scripting variables that are created/modified by a tag (at run-time). This information is provided - * by TagExtraInfo classes and it is used by the translation phase of JSP. + * by TagExtraInfo classes, and it is used by the translation phase of JSP. * <p> * Scripting variables generated by a custom action have an associated scope of either AT_BEGIN, NESTED, or AT_END. * <p> @@ -146,7 +146,7 @@ package jakarta.servlet.jsp.tagext; * <B>Variable Information in the TLD</B> * <p> * Scripting variable information can also be encoded directly for most cases into the Tag Library Descriptor using the - * <variable> subelement of the <tag> element. See the JSP specification. + * <variable> sub element of the <tag> element. See the JSP specification. */ public class VariableInfo { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org