Index: webtier-extensions/src/java/com/sun/appserv/web/cache/filter/CachingFilter.java =================================================================== RCS file: /cvs/glassfish/webtier-extensions/src/java/com/sun/appserv/web/cache/filter/CachingFilter.java,v retrieving revision 1.4 diff -u -r1.4 CachingFilter.java --- webtier-extensions/src/java/com/sun/appserv/web/cache/filter/CachingFilter.java 25 Dec 2005 04:29:25 -0000 1.4 +++ webtier-extensions/src/java/com/sun/appserv/web/cache/filter/CachingFilter.java 24 Aug 2010 07:12:13 -0000 @@ -204,55 +204,56 @@ // call the target resource try { chain.doFilter(srequest, (ServletResponse)wrapper); + // see if the there weren't any errors + if (!wrapper.isError()) { + // create/refresh the cached response entry + + // compute the timeout + int timeout = helper.getTimeout(request); + + // previous entry gets replaced + entry = wrapper.cacheResponse(); + + if (timeout == CacheHelper.TIMEOUT_VALUE_NOT_SET) { + // extracts this from the Expires: date header + Long lval = wrapper.getExpiresDateHeader(); + + if (lval == null) { + timeout = manager.getDefaultTimeout(); + entry.computeExpireTime(timeout); + } else { + long expireTime = lval.longValue(); + + // set the time this entry would expires + entry.setExpireTime(expireTime); + } + } else { + entry.computeExpireTime(timeout); + } + + oldEntry = (HttpCacheEntry)cache.put(key, entry, + entry.getSize()); + } else { + /** either there was an error or response from this + * resource is not cacheable anymore; so, remove the + * old entry from the cache. + */ + oldEntry = (HttpCacheEntry)cache.remove(key); + } } catch (ServletException se) { wrapper.clear(); throw se; } catch (IOException ioe) { wrapper.clear(); throw ioe; + } finally { + cache.notifyRefresh(index); } - // see if the there weren't any errors if (!wrapper.isError()) { - // create/refresh the cached response entry - - // compute the timeout - int timeout = helper.getTimeout(request); - - // previous entry gets replaced - entry = wrapper.cacheResponse(); - - if (timeout == CacheHelper.TIMEOUT_VALUE_NOT_SET) { - // extracts this from the Expires: date header - Long lval = wrapper.getExpiresDateHeader(); - - if (lval == null) { - timeout = manager.getDefaultTimeout(); - entry.computeExpireTime(timeout); - } else { - long expireTime = lval.longValue(); - - // set the time this entry would expires - entry.setExpireTime(expireTime); - } - } else { - entry.computeExpireTime(timeout); - } - - oldEntry = (HttpCacheEntry)cache.put(key, entry, - entry.getSize()); - cache.notifyRefresh(index); - // transmit the response body content writeBody(entry, response); - } else { - /** either there was an error or response from this - * resource is not cacheable anymore; so, remove the - * old entry from the cache. - */ - oldEntry = (HttpCacheEntry)cache.remove(key); } - // clear the wrapper (XXX: cache these??) wrapper.clear(); }