History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CACHE-129
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Lars Torunski
Reporter: Simone Avogadro
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
OSCache

CacheFilter will create useless sessions for application-scope pages

Created: 12/Jan/05 07:09 AM   Updated: 21/Jan/07 01:55 PM
Component/s: Filters
Affects Version/s: 2.0.2
Fix Version/s: 2.2 RC


 Description  « Hide
there is a problem on how the cache is found and an application-wide (i.e.: session independent) cache will create sessions wich are useless and are likely to pollute the app-server memory.

This is due to:
        Cache cache = admin.getCache(httpRequest, cacheScope);
which does response.getSession()
when serving application-scope cache this should be replaced with:
        Cache cache = admin.getAppScopeCache( sc );

 All   Comments   Change History      Sort Order:
Andres March - [14/Jan/05 07:29 PM ]
Please indicate a class which has this issue and I will have a look.

Simone Avogadro - [17/Jan/05 03:13 AM ]
version: 2.0.2
package: com.opensymphony.oscache.web.filter
class: CacheFilter
method: doFilter
the firts 4 lines are:
        log.info("<cache>: filter in scope " + cacheScope);

HttpServletRequest httpRequest = (HttpServletRequest) request;
        String key = admin.generateEntryKey(null, httpRequest, cacheScope);
        Cache cache = admin.getCache(httpRequest, cacheScope);

The 4th line is the problem, because if calls:

com.opensymphony.oscache.web.ServletCacheAdministrator.getCache:
    public Cache getCache(HttpServletRequest request, int scope) {
        if (scope == PageContext.APPLICATION_SCOPE) {
          return getAppScopeCache(request.getSession(true).getServletContext());
        }

[...]
    }

as you see in case of scope == PageContext.APPLICATION_SCOPE there is a call to
 request.getSession(true)
which creates a new session.
The real problem is that this is the only way to get the ServletContext, so I made my own modified Filter class which notes down the ServletContext during the init() method and then
uses it to do the work.






Lars Torunski - [02/Feb/05 05:08 PM ]
this is no duplicate

Lars Torunski - [02/Feb/05 05:09 PM ]
I added

Cache cache;
        if (cacheScope == PageContext.APPLICATION_SCOPE) {
            cache = admin.getAppScopeCache(config.getServletContext());
        } else {
            cache = admin.getCache(httpRequest, cacheScope);
        }

to the CacheFilter which should fix this.