Drop Servlet 2.5 runtime compatibility

Issue: SPR-13189
This commit is contained in:
Juergen Hoeller
2016-07-04 23:31:21 +02:00
parent ff6ead1fff
commit ae0b7c26c5
10 changed files with 59 additions and 219 deletions

View File

@@ -162,11 +162,6 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
private static final String INIT_PARAM_DELIMITERS = ",; \t\n";
/** Checking for Servlet 3.0+ HttpServletResponse.getStatus() */
private static final boolean responseGetStatusAvailable =
ClassUtils.hasMethod(HttpServletResponse.class, "getStatus");
/** ServletContext attribute to find the WebApplicationContext in */
private String contextAttribute;
@@ -912,8 +907,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
}
}
// Use response wrapper for Servlet 2.5 compatibility where
// the getHeader() method does not exist
// Use response wrapper in order to always add PATCH to the allowed methods
super.doOptions(request, new HttpServletResponseWrapper(response) {
@Override
public void setHeader(String name, String value) {
@@ -1069,13 +1063,12 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
if (this.publishEvents) {
// Whether or not we succeeded, publish an event.
long processingTime = System.currentTimeMillis() - startTime;
int statusCode = (responseGetStatusAvailable ? response.getStatus() : -1);
this.webApplicationContext.publishEvent(
new ServletRequestHandledEvent(this,
request.getRequestURI(), request.getRemoteAddr(),
request.getMethod(), getServletConfig().getServletName(),
WebUtils.getSessionId(request), getUsernameForRequest(request),
processingTime, failureCause, statusCode));
processingTime, failureCause, response.getStatus()));
}
}

View File

@@ -80,10 +80,6 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
protected static final String HEADER_CACHE_CONTROL = "Cache-Control";
/** Checking for Servlet 3.0+ HttpServletResponse.getHeaders(String) */
private static final boolean servlet3Present =
ClassUtils.hasMethod(HttpServletResponse.class, "getHeaders", String.class);
/** Set of supported HTTP methods */
private Set<String> supportedMethods;
@@ -263,8 +259,6 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
* subject to content negotiation and variances based on the value of the
* given request headers. The configured request header names are added only
* if not already present in the response "Vary" header.
* <p><strong>Note:</strong> This property is only supported on Servlet 3.0+
* which allows checking existing response header values.
* @param varyByRequestHeaders one or more request header names
* @since 4.3
*/
@@ -398,7 +392,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
else {
applyCacheSeconds(response, this.cacheSeconds);
}
if (servlet3Present && this.varyByRequestHeaders != null) {
if (this.varyByRequestHeaders != null) {
for (String value : getVaryRequestHeadersToAdd(response)) {
response.addHeader("Vary", value);
}