Bug 63968 - ExpiresFilter: invalid cast
Summary: ExpiresFilter: invalid cast
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.5.49
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-27 14:42 UTC by cpils
Modified: 2019-11-27 17:00 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.