Polishing

This commit is contained in:
Juergen Hoeller 2022-12-23 15:14:11 +01:00
parent d5ff232246
commit 254c3725e2
4 changed files with 16 additions and 14 deletions

View File

@ -89,6 +89,7 @@ class ResourceEntityResolverTests {
} }
} }
private static class ConfigurableFallbackEntityResolver extends ResourceEntityResolver { private static class ConfigurableFallbackEntityResolver extends ResourceEntityResolver {
private final boolean shouldThrow; private final boolean shouldThrow;
@ -98,7 +99,6 @@ class ResourceEntityResolverTests {
boolean fallbackInvoked = false; boolean fallbackInvoked = false;
private ConfigurableFallbackEntityResolver(boolean shouldThrow) { private ConfigurableFallbackEntityResolver(boolean shouldThrow) {
super(new NoOpResourceLoader()); super(new NoOpResourceLoader());
this.shouldThrow = shouldThrow; this.shouldThrow = shouldThrow;
@ -111,9 +111,8 @@ class ResourceEntityResolverTests {
this.returnValue = returnValue; this.returnValue = returnValue;
} }
@Nullable
@Override @Override
@Nullable
protected InputSource resolveSchemaEntity(String publicId, String systemId) { protected InputSource resolveSchemaEntity(String publicId, String systemId) {
this.fallbackInvoked = true; this.fallbackInvoked = true;
if (this.shouldThrow) { if (this.shouldThrow) {
@ -123,6 +122,8 @@ class ResourceEntityResolverTests {
} }
} }
@SuppressWarnings("serial")
static class ResolutionRejectedException extends RuntimeException {} static class ResolutionRejectedException extends RuntimeException {}
} }

View File

@ -51,7 +51,7 @@ import static org.mockito.Mockito.verify;
*/ */
public class SQLErrorCodeSQLExceptionTranslatorTests { public class SQLErrorCodeSQLExceptionTranslatorTests {
private static SQLErrorCodes ERROR_CODES = new SQLErrorCodes(); private static final SQLErrorCodes ERROR_CODES = new SQLErrorCodes();
static { static {
ERROR_CODES.setBadSqlGrammarCodes("1", "2"); ERROR_CODES.setBadSqlGrammarCodes("1", "2");
ERROR_CODES.setInvalidResultSetAccessCodes("3", "4"); ERROR_CODES.setInvalidResultSetAccessCodes("3", "4");
@ -64,6 +64,7 @@ public class SQLErrorCodeSQLExceptionTranslatorTests {
} }
@SuppressWarnings("deprecation")
@Test @Test
public void errorCodeTranslation() { public void errorCodeTranslation() {
SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES); SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);

View File

@ -116,9 +116,9 @@ import org.springframework.web.util.WebUtils;
* {@link org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator}. * {@link org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator}.
* *
* <li>The dispatcher's strategy for resolving multipart requests is determined by a * <li>The dispatcher's strategy for resolving multipart requests is determined by a
* {@link org.springframework.web.multipart.MultipartResolver} implementation. An * {@link org.springframework.web.multipart.MultipartResolver} implementation.
* implementation for Servlet 3 is included. The MultipartResolver bean name is * An implementation for standard Servlet multipart processing is included.
* "multipartResolver"; default is none. * The MultipartResolver bean name is "multipartResolver"; default is none.
* *
* <li>Its locale resolution strategy is determined by a {@link LocaleResolver}. * <li>Its locale resolution strategy is determined by a {@link LocaleResolver}.
* Out-of-the-box implementations work via HTTP accept header, cookie, or session. * 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; private LocaleResolver localeResolver;
/** ThemeResolver used by this servlet. */ /** ThemeResolver used by this servlet. */
@Nullable
@Deprecated @Deprecated
@Nullable
private ThemeResolver themeResolver; private ThemeResolver themeResolver;
/** List of HandlerMappings used by this servlet. */ /** List of HandlerMappings used by this servlet. */
@ -808,8 +808,8 @@ public class DispatcherServlet extends FrameworkServlet {
* @return the ThemeSource, if any * @return the ThemeSource, if any
* @see #getWebApplicationContext() * @see #getWebApplicationContext()
*/ */
@Nullable
@Deprecated @Deprecated
@Nullable
public final org.springframework.ui.context.ThemeSource getThemeSource() { public final org.springframework.ui.context.ThemeSource getThemeSource() {
return (getWebApplicationContext() instanceof org.springframework.ui.context.ThemeSource ? return (getWebApplicationContext() instanceof org.springframework.ui.context.ThemeSource ?
(org.springframework.ui.context.ThemeSource) getWebApplicationContext() : null); (org.springframework.ui.context.ThemeSource) getWebApplicationContext() : null);

View File

@ -171,8 +171,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
/** /**
* HTTP methods supported by {@link jakarta.servlet.http.HttpServlet}. * HTTP methods supported by {@link jakarta.servlet.http.HttpServlet}.
*/ */
private static final Set<String> HTTP_SERVLET_METHODS = Set.of("DELETE", "HEAD", "GET", "OPTIONS", "POST", "PUT", private static final Set<String> HTTP_SERVLET_METHODS =
"TRACE"); Set.of("DELETE", "HEAD", "GET", "OPTIONS", "POST", "PUT", "TRACE");
/** ServletContext attribute to find the WebApplicationContext in. */ /** ServletContext attribute to find the WebApplicationContext in. */
@ -866,7 +866,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
public void destroy() { public void destroy() {
getServletContext().log("Destroying Spring FrameworkServlet '" + getServletName() + "'"); getServletContext().log("Destroying Spring FrameworkServlet '" + getServletName() + "'");
// Only call close() on WebApplicationContext if locally managed... // 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(); cac.close();
} }
} }
@ -1131,8 +1132,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
logger.debug("Exiting from \"" + dispatchType + "\" dispatch, status " + status + headers); logger.debug("Exiting from \"" + dispatchType + "\" dispatch, status " + status + headers);
} }
else { else {
HttpStatusCode httpStatus = HttpStatusCode.valueOf(status); logger.debug("Completed " + HttpStatusCode.valueOf(status) + headers);
logger.debug("Completed " + httpStatus + headers);
} }
} }