Skip to content

Commit 95d7f88

Browse files
committed
Deprecate LastModified
See gh-27075
1 parent 25131eb commit 95d7f88

File tree

12 files changed

+36
-24
lines changed

12 files changed

+36
-24
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ private void logRequest(HttpServletRequest request) {
10201020
* @param response current HTTP response
10211021
* @throws Exception in case of any kind of processing failure
10221022
*/
1023+
@SuppressWarnings("deprecation")
10231024
protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
10241025
HttpServletRequest processedRequest = request;
10251026
HandlerExecutionChain mappedHandler = null;

spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerAdapter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,9 +83,10 @@ public interface HandlerAdapter {
8383
* @param request current HTTP request
8484
* @param handler the handler to use
8585
* @return the lastModified value for the given handler
86-
* @see javax.servlet.http.HttpServlet#getLastModified
87-
* @see org.springframework.web.servlet.mvc.LastModified#getLastModified
86+
* @deprecated as of 5.3.9 along with
87+
* {@link org.springframework.web.servlet.mvc.LastModified}.
8888
*/
89+
@Deprecated
8990
long getLastModified(HttpServletRequest request, Object handler);
9091

9192
}

spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/HandlerFunctionAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -157,6 +157,7 @@ else if (result == null) {
157157
}
158158

159159
@Override
160+
@SuppressWarnings("deprecation")
160161
public long getLastModified(HttpServletRequest request, Object handler) {
161162
return -1L;
162163
}

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletHandlerAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,6 +69,7 @@ public ModelAndView handle(HttpServletRequest request, HttpServletResponse respo
6969
}
7070

7171
@Override
72+
@SuppressWarnings("deprecation")
7273
public long getLastModified(HttpServletRequest request, Object handler) {
7374
return -1;
7475
}

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/Controller.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -93,11 +93,12 @@
9393
* you all those references through convenient accessors but requires an
9494
* ApplicationContext reference on initialization.
9595
*
96-
* <p>Controllers can optionally implement the {@link LastModified} interface.
96+
* <p>Controllers can use the {@code checkNotModified} methods on
97+
* {@link org.springframework.web.context.request.WebRequest} for HTTP caching
98+
* support.
9799
*
98100
* @author Rod Johnson
99101
* @author Juergen Hoeller
100-
* @see LastModified
101102
* @see SimpleControllerHandlerAdapter
102103
* @see AbstractController
103104
* @see org.springframework.mock.web.MockHttpServletRequest

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/HttpRequestHandlerAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,7 +35,6 @@
3535
* @since 2.0
3636
* @see org.springframework.web.servlet.DispatcherServlet
3737
* @see org.springframework.web.HttpRequestHandler
38-
* @see LastModified
3938
* @see SimpleControllerHandlerAdapter
4039
*/
4140
public class HttpRequestHandlerAdapter implements HandlerAdapter {
@@ -55,6 +54,7 @@ public ModelAndView handle(HttpServletRequest request, HttpServletResponse respo
5554
}
5655

5756
@Override
57+
@SuppressWarnings("deprecation")
5858
public long getLastModified(HttpServletRequest request, Object handler) {
5959
if (handler instanceof LastModified) {
6060
return ((LastModified) handler).getLastModified(request);

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/LastModified.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,12 +34,18 @@
3434
*
3535
* @author Rod Johnson
3636
* @author Juergen Hoeller
37+
* @deprecated as of 5.3.9 in favor of using the {@code checkNotModified} methods
38+
* in {@link org.springframework.web.context.request.WebRequest}, or from an
39+
* annotated controller method, returning a
40+
* {@link org.springframework.http.ResponseEntity} with an "ETag" and/or
41+
* "Last-Modified" headers set.
3742
* @see javax.servlet.http.HttpServlet#getLastModified
3843
* @see Controller
3944
* @see SimpleControllerHandlerAdapter
4045
* @see org.springframework.web.HttpRequestHandler
4146
* @see HttpRequestHandlerAdapter
4247
*/
48+
@Deprecated
4349
public interface LastModified {
4450

4551
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/SimpleControllerHandlerAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@
3434
* @author Juergen Hoeller
3535
* @see org.springframework.web.servlet.DispatcherServlet
3636
* @see Controller
37-
* @see LastModified
3837
* @see HttpRequestHandlerAdapter
3938
*/
4039
public class SimpleControllerHandlerAdapter implements HandlerAdapter {
@@ -53,6 +52,7 @@ public ModelAndView handle(HttpServletRequest request, HttpServletResponse respo
5352
}
5453

5554
@Override
55+
@SuppressWarnings("deprecation")
5656
public long getLastModified(HttpServletRequest request, Object handler) {
5757
if (handler instanceof LastModified) {
5858
return ((LastModified) handler).getLastModified(request);

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -105,6 +105,7 @@ protected abstract ModelAndView handleInternal(HttpServletRequest request,
105105
* This implementation expects the handler to be an {@link HandlerMethod}.
106106
*/
107107
@Override
108+
@SuppressWarnings("deprecation")
108109
public final long getLastModified(HttpServletRequest request, Object handler) {
109110
return getLastModifiedInternal(request, (HandlerMethod) handler);
110111
}
@@ -114,7 +115,10 @@ public final long getLastModified(HttpServletRequest request, Object handler) {
114115
* @param request current HTTP request
115116
* @param handlerMethod handler method to use
116117
* @return the lastModified value for the given handler
118+
* @deprecated as of 5.3.9 along with
119+
* {@link org.springframework.web.servlet.mvc.LastModified}.
117120
*/
121+
@Deprecated
118122
protected abstract long getLastModifiedInternal(HttpServletRequest request, HandlerMethod handlerMethod);
119123

120124
}

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ protected ModelAndView handleInternal(HttpServletRequest request,
826826
* and return {@code null} if the result of that call is {@code true}.
827827
*/
828828
@Override
829+
@SuppressWarnings("deprecation")
829830
protected long getLastModifiedInternal(HttpServletRequest request, HandlerMethod handlerMethod) {
830831
return -1;
831832
}

0 commit comments

Comments
 (0)