roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r355667 - in /incubator/roller/trunk/src/org/roller/presentation/filters: FeedCacheFilter.java MainPageCacheFilter.java WeblogPageCacheFilter.java
Date Sat, 10 Dec 2005 00:45:08 GMT
Author: agilliland
Date: Fri Dec  9 16:45:05 2005
New Revision: 355667

URL: http://svn.apache.org/viewcvs?rev=355667&view=rev
Log:
more with exception handling.


Modified:
    incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java
    incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java
    incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java

Modified: incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java?rev=355667&r1=355666&r2=355667&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/FeedCacheFilter.java Fri Dec
 9 16:45:05 2005
@@ -88,13 +88,13 @@
         
         String key = "feedCache:"+this.generateKey(feedRequest);
         
-        ResponseContent respContent = (ResponseContent) this.mFeedCache.get(key);
-        if (respContent == null) {
-            
-            mLogger.debug("MISS "+key);
-            this.misses++;
-            
-            try {
+        try {
+            ResponseContent respContent = (ResponseContent) this.mFeedCache.get(key);
+            if (respContent == null) {
+                
+                mLogger.debug("MISS "+key);
+                this.misses++;
+                
                 CacheHttpServletResponseWrapper cacheResponse =
                         new CacheHttpServletResponseWrapper(response);
                 
@@ -113,28 +113,30 @@
                     mLogger.debug("Display exception "+key);
                 }
                 
-            } catch (java.net.SocketException se) {
-                // ignored
-                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-            } catch (Exception e) {
-                // something unexpected and bad happened
-                mLogger.error("Error rendering feed "+key, e);
-                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            } else {
+                
+                mLogger.debug("HIT "+key);
+                this.hits++;
+                
+                respContent.writeTo(response);
             }
             
-        } else {
-            
-            mLogger.debug("HIT "+key);
-            this.hits++;
+        } catch(Exception ex) {
             
-            try {
-                respContent.writeTo(response);
-            } catch (java.net.SocketException se) {
-                // ignored
-            } catch (Exception e) {
-                mLogger.error("Error with cached response "+key+" - "+e.getMessage());
+            if(ex.getMessage().indexOf("ClientAbort") != -1) {
+                // ClientAbortException ... ignored
+                mLogger.debug(ex.getMessage());
+                
+            } else if(ex.getMessage().indexOf("SocketException") != -1) {
+                // SocketException ... ignored
+                mLogger.debug(ex.getMessage());
+                
+            } else {
+                mLogger.error("Unexpected exception rendering feed "+key, ex);
             }
             
+            // gotta send something to the client
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
         
         mLogger.debug("exiting");
@@ -225,6 +227,7 @@
         }
         
         this.mFeedCache.remove(removeSet);
+        this.purges += removeSet.size();
     }
     
     

Modified: incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java?rev=355667&r1=355666&r2=355667&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/MainPageCacheFilter.java Fri
Dec  9 16:45:05 2005
@@ -56,7 +56,6 @@
     // for metrics
     private double hits = 0;
     private double misses = 0;
-    private double purges = 0;
     private double skips = 0;
     private Date startTime = new Date();
     
@@ -106,17 +105,17 @@
         }
         
         
-        ResponseContent respContent = null;
-        if(!this.excludeOwnerPages || prince == null) {
-            respContent = (ResponseContent) this.mPageCache.get(key);
-        }
-        
-        if (respContent == null) {
-            
-            mLogger.debug("MISS "+key);
-            this.misses++;
+        try {
+            ResponseContent respContent = null;
+            if(!this.excludeOwnerPages || prince == null) {
+                respContent = (ResponseContent) this.mPageCache.get(key);
+            }
             
-            try {
+            if(respContent == null) {
+
+                mLogger.debug("MISS "+key);
+                this.misses++;
+                
                 CacheHttpServletResponseWrapper cacheResponse =
                         new CacheHttpServletResponseWrapper(response);
                 
@@ -141,28 +140,30 @@
                     mLogger.debug("Display exception "+key);
                 }
                 
-            } catch (java.net.SocketException se) {
-                // ignored
-                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-            } catch (Exception e) {
-                // something unexpected and bad happened
-                mLogger.error("Error rendering page "+key, e);
-                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            } else {
+                
+                mLogger.debug("HIT "+key);
+                this.hits++;
+                
+                respContent.writeTo(response);
             }
             
-        } else {
-            
-            mLogger.debug("HIT "+key);
-            this.hits++;
+        } catch(Exception ex) {
             
-            try {
-                respContent.writeTo(response);
-            } catch (java.net.SocketException se) {
-                // ignored
-            } catch (Exception e) {
-                mLogger.error("Error with cached response "+key, e);
+            if(ex.getMessage().indexOf("ClientAbort") != -1) {
+                // ClientAbortException ... ignored
+                mLogger.debug(ex.getMessage());
+                
+            } else if(ex.getMessage().indexOf("SocketException") != -1) {
+                // SocketException ... ignored
+                mLogger.debug(ex.getMessage());
+                
+            } else {
+                mLogger.error("Unexpected exception rendering page "+key, ex);
             }
             
+            // gotta send something to the client
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
         
         mLogger.debug("exiting");
@@ -250,7 +251,6 @@
         this.startTime = new Date();
         this.hits = 0;
         this.misses = 0;
-        this.purges = 0;
         this.skips = 0;
     }
     
@@ -262,11 +262,10 @@
         stats.put("startTime", this.startTime);
         stats.put("hits", new Double(this.hits));
         stats.put("misses", new Double(this.misses));
-        stats.put("purges", new Double(this.purges));
         stats.put("skips", new Double(this.skips));
         
         // calculate efficiency
-        if((misses - purges) > 0) {
+        if(misses > 0) {
             double efficiency = hits / (misses + hits);
             stats.put("efficiency", new Double(efficiency * 100));
         }

Modified: incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java?rev=355667&r1=355666&r2=355667&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/filters/WeblogPageCacheFilter.java
Fri Dec  9 16:45:05 2005
@@ -39,6 +39,7 @@
 import org.roller.presentation.util.CacheHttpServletResponseWrapper;
 import org.roller.presentation.util.ResponseContent;
 
+
 /**
  * A filter used for caching fully rendered weblog pages ... /page/*
  *
@@ -85,17 +86,17 @@
         
         String key = "pageCache:"+this.generateKey(pageRequest);
         
-        ResponseContent respContent = null;
-        if(!this.excludeOwnerPages || !pageRequest.isLoggedIn()) {
-            respContent = (ResponseContent) this.mPageCache.get(key);
-        }
-        
-        if (respContent == null) {
-            
-            mLogger.debug("MISS "+key);
-            this.misses++;
+        try {
+            ResponseContent respContent = null;
+            if(!this.excludeOwnerPages || !pageRequest.isLoggedIn()) {
+                respContent = (ResponseContent) this.mPageCache.get(key);
+            }
             
-            try {
+            if (respContent == null) {
+                
+                mLogger.debug("MISS "+key);
+                this.misses++;
+                
                 CacheHttpServletResponseWrapper cacheResponse =
                         new CacheHttpServletResponseWrapper(response);
                 
@@ -121,28 +122,30 @@
                     mLogger.debug("Display exception "+key);
                 }
                 
-            } catch (java.net.SocketException se) {
-                // ignored
-                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-            } catch (Exception e) {
-                // something unexpected and bad happened
-                mLogger.error("Error rendering page "+key, e);
-                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            } else {
+                
+                mLogger.debug("HIT "+key);
+                this.hits++;
+                
+                respContent.writeTo(response);
             }
             
-        } else {
-            
-            mLogger.debug("HIT "+key);
-            this.hits++;
+        } catch(Exception ex) {
             
-            try {
-                respContent.writeTo(response);
-            } catch (java.net.SocketException se) {
-                // ignored
-            } catch (Exception e) {
-                mLogger.error("Error with cached response "+key, e);
+            if(ex.getMessage().indexOf("ClientAbort") != -1) {
+                // ClientAbortException ... ignored
+                mLogger.debug(ex.getMessage());
+                
+            } else if(ex.getMessage().indexOf("SocketException") != -1) {
+                // SocketException ... ignored
+                mLogger.debug(ex.getMessage());
+                
+            } else {
+                mLogger.error("Unexpected exception rendering page "+key, ex);
             }
             
+            // gotta send something to the client
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
         }
         
         mLogger.debug("exiting");
@@ -244,6 +247,7 @@
         }
         
         this.mPageCache.remove(removeSet);
+        this.purges += removeSet.size();
     }
     
     
@@ -272,6 +276,7 @@
         }
         
         this.mPageCache.remove(removeSet);
+        this.purges += removeSet.size();
     }
     
     



Mime
View raw message