ffang commented on PR #3752: URL: https://github.com/apache/cxf/pull/3752#issuecomment-7140265533
> Thanks for the update, nearly all of my earlier comments are addressed. A few small things left: > > 1. **Static strong refs in `JCacheUtils`** (nit, still open): `CACHES`/`MANAGERS` hold managers and caches strongly in static maps. If an app undeploys without closing, say an OAuth provider or a token store, its class loader stays pinned. Weak identity references would be safer, or at least a note that every user must close. > 2. **Cache reference leak if `isUsedBy` throws** (nit): in the `JCacheReplayCache` constructor, the cache is acquired through `JCacheUtils.getOrCreate` before `EhcacheReplayExpiry.isUsedBy(...)` runs. `isUsedBy` only catches `IllegalArgumentException`. If it throws anything else, the outer `catch (Exception)` turns that into a `WSSecurityException` but never releases the cache, so its count never reaches zero. Catching more broadly in `isUsedBy`, or releasing in the outer catch, would cover it. > 3. **Identifiers can be held for less than their validity** (pre-existing, not from this PR): on the fallback path every identifier is held 1h, whatever its own expiry. On both paths, an expiry beyond 12h is reset to 1h, which matches WSS4J's `EHCacheExpiry`. For OneTimeUse assertions `getMaxTTL()` makes WSS4J reject the long ones, but other identifiers (such as SAML assertion IDs with a long NotOnOrAfter) can drop out of the cache while still valid. Maybe worth a follow-up. Thanks @coheigea. Points 1 and 2 are addressed in ebf7a16c7a. Point 3 needed no code change here. **1. Static strong refs.** I've kept strong references for the reasons in my previous reply, and added the note you suggested to the `JCacheUtils` Javadoc: caches and managers are held until released, so every user must close the replay cache, token store or data provider that obtained them, or the application's class loader stays reachable after undeploy. With the previous update, all CXF users (including STS and XKMS) release what they obtain. **2. Cache reference leak.** Fixed. The `JCacheReplayCache` constructor now releases the cache it acquired if anything fails after acquiring it, including `isUsedBy`. I checked it by forcing `isUsedBy` to throw: before the fix the cache stays registered, after it it's destroyed. **3. Identifiers held for less than their validity.** Agreed. This matches WSS4J's `EHCacheExpiry` and predates this PR, so I'd keep it out of this one and open a follow-up JIRA. One option there is to reject or flag identifiers whose expiry exceeds `getMaxTTL()` for more than OneTimeUse assertions. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
