diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java index 67d08abcf3..f56d4dc53b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java @@ -20,7 +20,6 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import java.util.concurrent.TimeUnit; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessor.java index 48552d7202..4d851cd70f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessor.java @@ -59,9 +59,6 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv */ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverterMethodProcessor { - private static final List SUPPORTED_METHODS = - Arrays.asList(HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH); - /** * Basic constructor with converters only. Suitable for resolving * {@code @RequestBody}. For handling {@code @ResponseBody} consider also diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java index b4628118bf..56506cba8a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java @@ -170,7 +170,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { private class CacheSection implements SectionTransformer { - private final String COMMENT_DIRECTIVE = "#"; + private static final String COMMENT_DIRECTIVE = "#"; @Override public String transform(String line, HashBuilder builder, Resource resource, diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java index 038accde19..0f8700c4a2 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java @@ -199,6 +199,8 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { /** * Return whether the HTTP 1.0 expires header is used. + * + * @deprecated in favor of {@link #getCacheControl}. */ @Deprecated public final boolean isUseExpiresHeader() { @@ -220,6 +222,8 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { /** * Return whether the HTTP 1.1 cache-control header is used. + * + * @deprecated in favor of {@link #getCacheControl}. */ @Deprecated public final boolean isUseCacheControlHeader() { @@ -240,6 +244,8 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { /** * Return whether the HTTP 1.1 cache-control header value "no-store" is used. + * + * @deprecated in favor of {@link #getCacheControl}. */ @Deprecated public final boolean isUseCacheControlNoStore() { @@ -262,6 +268,8 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { /** * Return whether 'must-revalidate' is added to every Cache-Control header. + * + * @deprecated in favor of {@link #getCacheControl}. */ @Deprecated public boolean isAlwaysMustRevalidate() { @@ -315,6 +323,17 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { checkAndPrepare(request, response, this.cacheControl); } + /** + * * Check and prepare the given request and response according to the settings + * of this generator. Checks for supported methods and a required session, + * and applies the number of cache seconds specified for this generator. + * @param request current HTTP request + * @param response current HTTP response + * @param lastModified whether the underlying handler writes "Last-Modified" headers; in that case, + * a "Cache-Control: must-revalidate" directive is set in the response. + * @throws ServletException if the request cannot be handled because a check failed + * @deprecated in favor of {@link #checkAndPrepare(HttpServletRequest, HttpServletResponse, CacheControl)}. + */ @Deprecated protected final void checkAndPrepare( HttpServletRequest request, HttpServletResponse response, boolean lastModified) @@ -362,10 +381,8 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { } // Check whether a session is required. - if (this.requireSession) { - if (request.getSession(false) == null) { - throw new HttpSessionRequiredException("Pre-existing session required but none found"); - } + if (this.requireSession && request.getSession(false) == null) { + throw new HttpSessionRequiredException("Pre-existing session required but none found"); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WebContentInterceptorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WebContentInterceptorTests.java index 047167e8c6..273a3c64d7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WebContentInterceptorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WebContentInterceptorTests.java @@ -18,7 +18,6 @@ package org.springframework.web.servlet.mvc; import static org.junit.Assert.*; -import java.util.List; import java.util.Properties; import org.hamcrest.Matchers;