From 254c3725e21d140e5eda38cead0f1a621c59b7bd Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 23 Dec 2022 15:14:11 +0100 Subject: [PATCH] Polishing --- .../beans/factory/xml/ResourceEntityResolverTests.java | 7 ++++--- .../SQLErrorCodeSQLExceptionTranslatorTests.java | 3 ++- .../springframework/web/servlet/DispatcherServlet.java | 10 +++++----- .../springframework/web/servlet/FrameworkServlet.java | 10 +++++----- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ResourceEntityResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ResourceEntityResolverTests.java index b6904fce9f..68662e6c48 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ResourceEntityResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ResourceEntityResolverTests.java @@ -89,6 +89,7 @@ class ResourceEntityResolverTests { } } + private static class ConfigurableFallbackEntityResolver extends ResourceEntityResolver { private final boolean shouldThrow; @@ -98,7 +99,6 @@ class ResourceEntityResolverTests { boolean fallbackInvoked = false; - private ConfigurableFallbackEntityResolver(boolean shouldThrow) { super(new NoOpResourceLoader()); this.shouldThrow = shouldThrow; @@ -111,9 +111,8 @@ class ResourceEntityResolverTests { this.returnValue = returnValue; } - - @Nullable @Override + @Nullable protected InputSource resolveSchemaEntity(String publicId, String systemId) { this.fallbackInvoked = true; if (this.shouldThrow) { @@ -123,6 +122,8 @@ class ResourceEntityResolverTests { } } + + @SuppressWarnings("serial") static class ResolutionRejectedException extends RuntimeException {} } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java index 486ffbf9a8..d185cfaa74 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java @@ -51,7 +51,7 @@ import static org.mockito.Mockito.verify; */ public class SQLErrorCodeSQLExceptionTranslatorTests { - private static SQLErrorCodes ERROR_CODES = new SQLErrorCodes(); + private static final SQLErrorCodes ERROR_CODES = new SQLErrorCodes(); static { ERROR_CODES.setBadSqlGrammarCodes("1", "2"); ERROR_CODES.setInvalidResultSetAccessCodes("3", "4"); @@ -64,6 +64,7 @@ public class SQLErrorCodeSQLExceptionTranslatorTests { } + @SuppressWarnings("deprecation") @Test public void errorCodeTranslation() { SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index 1ea651d3b8..5edace6e40 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -116,9 +116,9 @@ import org.springframework.web.util.WebUtils; * {@link org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator}. * *
  • The dispatcher's strategy for resolving multipart requests is determined by a - * {@link org.springframework.web.multipart.MultipartResolver} implementation. An - * implementation for Servlet 3 is included. The MultipartResolver bean name is - * "multipartResolver"; default is none. + * {@link org.springframework.web.multipart.MultipartResolver} implementation. + * An implementation for standard Servlet multipart processing is included. + * The MultipartResolver bean name is "multipartResolver"; default is none. * *
  • Its locale resolution strategy is determined by a {@link LocaleResolver}. * Out-of-the-box implementations work via HTTP accept header, cookie, or session. @@ -318,8 +318,8 @@ public class DispatcherServlet extends FrameworkServlet { private LocaleResolver localeResolver; /** ThemeResolver used by this servlet. */ - @Nullable @Deprecated + @Nullable private ThemeResolver themeResolver; /** List of HandlerMappings used by this servlet. */ @@ -808,8 +808,8 @@ public class DispatcherServlet extends FrameworkServlet { * @return the ThemeSource, if any * @see #getWebApplicationContext() */ - @Nullable @Deprecated + @Nullable public final org.springframework.ui.context.ThemeSource getThemeSource() { return (getWebApplicationContext() instanceof org.springframework.ui.context.ThemeSource ? (org.springframework.ui.context.ThemeSource) getWebApplicationContext() : null); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java index 25cf390494..32a9993f38 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java @@ -171,8 +171,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic /** * HTTP methods supported by {@link jakarta.servlet.http.HttpServlet}. */ - private static final Set HTTP_SERVLET_METHODS = Set.of("DELETE", "HEAD", "GET", "OPTIONS", "POST", "PUT", - "TRACE"); + private static final Set HTTP_SERVLET_METHODS = + Set.of("DELETE", "HEAD", "GET", "OPTIONS", "POST", "PUT", "TRACE"); /** ServletContext attribute to find the WebApplicationContext in. */ @@ -866,7 +866,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic public void destroy() { getServletContext().log("Destroying Spring FrameworkServlet '" + getServletName() + "'"); // Only call close() on WebApplicationContext if locally managed... - if (!this.webApplicationContextInjected && this.webApplicationContext instanceof ConfigurableApplicationContext cac) { + if (!this.webApplicationContextInjected && + this.webApplicationContext instanceof ConfigurableApplicationContext cac) { cac.close(); } } @@ -1131,8 +1132,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic logger.debug("Exiting from \"" + dispatchType + "\" dispatch, status " + status + headers); } else { - HttpStatusCode httpStatus = HttpStatusCode.valueOf(status); - logger.debug("Completed " + httpStatus + headers); + logger.debug("Completed " + HttpStatusCode.valueOf(status) + headers); } }