[MGNLCACHE-154] Requests initiated with ERROR dispatcher do not work with CacheFilter Created: 21/Nov/16  Updated: 16/Feb/17  Resolved: 01/Dec/16

Status: Closed
Project: Cache Modules
Component/s: cache core
Affects Version/s: 5.5
Fix Version/s: 5.5.1

Type: Bug Priority: Neutral
Reporter: Tommi Salonen Assignee: Roman Kovařík
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 50m
Original Estimate: Not Specified

Issue Links:
Relates
causality
caused by MGNLCACHE-147 Cache filter is not triggered for for... Closed
dependency
is depended upon by MGNLCE-66 Integration tests for error pages Closed
duplicate
is duplicated by MAGNOLIA-6886 NullPointerExceptions in Personalized... Closed
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Sprint: Kromeriz 73
Story Points: 5

 Description   

Before 5.5, CacheFilter was not executed for requests initiated with the ERROR dispatcher, because CacheFilter extended OncePerRequestAbstractMgnlFilter.

In 5.5, CacheFilter does not extend OncePerRequestAbstractMgnlFilter anymore which causes the CacheFilter to be executed twice for example when requesting page that does not exist. Both executions share the same cache key so in the second request (initiated with the ERROR dispatcher) an empty response is returned.

This leads to error-pages (defined in web.xml) not working.

If CacheFilter is disabled or error-pages excluded from caching by other means, then they are working as expected.



 Comments   
Comment by Roman Kovařík [ 23/Nov/16 ]

Hello ttsalonen
could you attach your configuration of the error handler (web.xml and export related virtual URI mappings)?

Regards
Roman

Comment by Tommi Salonen [ 24/Nov/16 ]

In web.xml:

<error-page>
<error-code>404</error-code>
<location>/error-404</location>
</error-page>

/error-404 page is a normal page within the site structure. There are no related virtualURIMappings.

Comment by Roman Kovařík [ 24/Nov/16 ]

I was able to reproduce the issue and investigate:

  1. /non-existing page is cached as an cache error.
  2. Error dispatcher requests an error page /error-404 which is not a static resource but exists in the website workspace.
  3. Cache filter uses the original URI as part of the cached key and requests the item cached for /non-existing.
  4. Since the cached item is the error item, the error is returned and the error page is never reached.

Solution:

  1. info.magnolia.cms.util.ServletUtil#getOriginalRequestURI() handles the forward case so it should handle also the error case.
  2. Get the URI from javax.servlet.error.request_uri if it exists.

Workaround:

  1. Configure bypass on the cache filter to bypass the error page.
Generated at Sun Feb 11 23:52:44 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.