Broadleaf Microservices
  • v1.0.0-latest-prod

Content Release Notes for 2.0.7-GA

Bug Fixes

Hydrated Content Item Cache Misconfiguration and Improper Invalidation

In Content Services 2.0.6-GA, DefaultContentItemHydrationService was updated to use a new hydrationCacheByContentItemIdAndPreviewToken cache.

This cache was not configured with a natural TTL expiration, nor was it being invalidated upon receipt of ContentCacheInvalidationEvent.

As a result, it was possible to see stale data returned when requests were made to the /content-item-resolver endpoint.

The following fixes resolve the aforementioned issues:

  • Updated DefaultContentItemHydrationService.onApplicationEvent to invalidate hydrationCacheByContentItemIdAndPreviewToken upon receipt of ContentCacheInvalidationEvent

  • Introduced a new broadleaf.content.cache.hydrated-by-content-item-id-and-preview-token-ttl configuration property to allow defining the maximum TTL of the hydrationCacheByContentItemIdAndPreviewToken.

Workaround in Lieu of Upgrade

If you are currently on Content Services 2.0.6-GA and cannot immediately upgrade to this release, you can follow the below steps to temporarily mitigate the issue until you are ready to upgrade.

Note
In this approach, we add the cache invalidation changes, but the TTL of the cache will still be unbounded as before. This is not a problem, as cache invalidation in response to entity changes will largely dominate over any TTL settings anyway.
  1. In your project, define an extension of DefaultContentItemHydrationService.

  2. Ensure you register this extension as a bean in your ContentServices Spring configuration.

  3. In your DefaultContentItemHydrationService extension, introduce the following method override:

    // TODO - remove this after upgrading ContentServices beyond 2.0.6-GA
    @Override
    public void onApplicationEvent(ContentCacheInvalidationEvent event) {
        super.onApplicationEvent(event);
        if (getCacheStateManager() != null && shouldInvalidateCache(event)) {
            getCacheStateManager().invalidate(
                    DefaultContentItemHydrationService.BY_CONTENT_ITEM_ID_AND_PREVIEW_TOKEN);
        }
    }