Bug 57331

Summary: Allow ExpiresFilter to use "year" as synonym for "years" in its configuration
Product: Tomcat 7 Reporter: Konstantin Kolinko <knst.kolinko>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 7.0.57   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Konstantin Kolinko 2014-12-08 21:37:10 UTC
The current code is

            if ("years".equalsIgnoreCase(currentToken)) {
                durationUnit = DurationUnit.YEAR;
            } else if ("month".equalsIgnoreCase(currentToken) ||
                    "months".equalsIgnoreCase(currentToken)) {
                durationUnit = DurationUnit.MONTH;
            ...

The above if/else tree misses "year" case. All other time units have support for singular form, e.g. "months"/"month" above.

This was observed by a stackoverflow user [1]. 
The following configuration fails:

  <init-param>
   <param-name>ExpiresDefault</param-name>
   <param-value>access plus 1 year</param-value>
 </init-param>

but succeeds if one replaces s/year/years/.


[1] http://stackoverflow.com/questions/27353512/how-to-configure-expires-filter-in-tomcat-7
Comment 1 Konstantin Kolinko 2014-12-09 01:00:00 UTC
Fixed in Tomcat 7, 8, trunk. It will be in 7.0.58, 8.0.16 onwards.

(revisions 1643963, 1643964, 1643965)