commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nico...@apache.org
Subject svn commit: r745082 - /commons/sandbox/monitoring/branches/modules/reporting/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java
Date Tue, 17 Feb 2009 14:06:39 GMT
Author: nicolas
Date: Tue Feb 17 14:06:39 2009
New Revision: 745082

URL: http://svn.apache.org/viewvc?rev=745082&view=rev
Log:
handle exception during loggin

Modified:
    commons/sandbox/monitoring/branches/modules/reporting/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java

Modified: commons/sandbox/monitoring/branches/modules/reporting/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/reporting/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java?rev=745082&r1=745081&r2=745082&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/reporting/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java
(original)
+++ commons/sandbox/monitoring/branches/modules/reporting/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java
Tue Feb 17 14:06:39 2009
@@ -78,12 +78,30 @@
         {
             public void run()
             {
-                Repository observed = observeRepositoryForPeriod();
-                log( observed );
+                try
+                {
+                    Repository observed = observeRepositoryForPeriod();
+                    log( observed );
+                }
+                catch ( Throwable t )
+                {
+                    handleLogError( t );
+                }
             }
         }, delay, period, TimeUnit.MILLISECONDS );
     }
 
+    /**
+     * An error occured during logging. To avoid the scheduler to stop we catch any throwable.
By default we just log to
+     * System.err, this method is expected to be overriden.
+     * 
+     * @param t error
+     */
+    protected void handleLogError( Throwable t )
+    {
+        t.printStackTrace( System.err );
+    }
+
     private Repository observeRepositoryForPeriod()
     {
         ObserverRepository previous = this.secondary;



Mime
View raw message