Bug 63968

Summary: ExpiresFilter: invalid cast
Product: Tomcat 8 Reporter: cpils <cpils>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.5.49   
Target Milestone: ----   
Hardware: PC   
OS: Linux   

Description cpils 2019-11-27 14:42:09 UTC
The getExpirationDate() Method of the ExpiresFilter throws a ClassCastException when the following conditions hold:
1. the request is ServletRequestWrapper
2. an inner request implements the interface org.apache.catalina.servlet4preview.http.HttpServletRequest

Then the method will throw a ClassCastException in line 1296 of org.apache.catalina.filters.ExpiresFilter.

Log Message observed:
Our application uses a custom implementation of a ServletRequestWrapper. The ClassCastException logs that our custom implementation cannot be cast to org.apache.catalina.servlet4preview.http.HttpServletRequest

Root Cause
==========
The root cause is that if-conditon in line 1295 checks that innerRequest is an instance of servlet4preview.http.HttpServletRequest, yet in line 1296 the request (rather than the innerRequest) is casted. 

Out Tomcat Settings:
====================
We use Tomcat 8.5.49 with Connector-Protocol org.apache.coyote.http11.Http11NioProtocol.
Comment 1 Mark Thomas 2019-11-27 17:00:19 UTC
Thanks for the report.

Fixed in:
- 8.5.x for 8.5.50 onwards

Only 8.5.x was affected.