[ 
https://issues.apache.org/jira/browse/CXF-9283?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Freeman Yue Fang resolved CXF-9283.
-----------------------------------
    Resolution: Fixed

> JCacheReplayCache holds an identifier that expires beyond the max TTL for the 
> default TTL only
> ----------------------------------------------------------------------------------------------
>
>                 Key: CXF-9283
>                 URL: https://issues.apache.org/jira/browse/CXF-9283
>             Project: CXF
>          Issue Type: Bug
>          Components: WS-* Components
>            Reporter: Freeman Yue Fang
>            Assignee: Freeman Yue Fang
>            Priority: Major
>             Fix For: 3.6.14, 4.2.5, 4.1.10
>
>
> h3. Description
> {{JCacheReplayCache}} (the WS-Security replay cache used with a JCache 
> provider) holds each identifier until its expiry, up to the max TTL of 12 
> hours ({{EHCacheExpiry.MAX_TTL}}). An expiry that is not in the future gets 
> the default TTL of 1 hour ({{EHCacheExpiry.DEFAULT_TTL}}).
> However, an expiry beyond the max TTL is also replaced by the default TTL, so:
> * an identifier that expires in 11 hours is held for 11 hours;
> * an identifier that expires in 13 hours is held for 1 hour.
> The cache reports {{getMaxTTL()}} as 12 hours when it uses Ehcache's 
> per-entry expiry, but an identifier with a long expiry is held for much less 
> than that.
> WSS4J's own replay caches cap such an expiry at their max TTL instead:
> * {{EHCacheExpiry.getExpiryForCreation}}: an expiry beyond 12 hours is held 
> for 12 hours;
> * {{MemoryReplayCache}}: an expiry beyond 1 hour is held for 1 hour.
> h3. Fix
> In {{JCacheReplayCache}}, hold an identifier whose expiry is beyond the max 
> TTL for the max TTL, as {{EHCacheExpiry}} does. An expiry that is missing or 
> not in the future still gets the default TTL.
> {code:java}
> if (expiry == null || !expiry.isAfter(now)) {
>     expiry = now.plusSeconds(EHCacheExpiry.DEFAULT_TTL);
> } else if (expiry.isAfter(now.plusSeconds(EHCacheExpiry.MAX_TTL))) {
>     expiry = now.plusSeconds(EHCacheExpiry.MAX_TTL);
> }
> {code}
> {{JCacheReplayCacheTest.testLongExpiryAndDefaultBounds}} now expects an 
> expiry beyond the max TTL to be held for the max TTL.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to