polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [4/6] zest-java git commit: ZEST-128 - Added unwinding of UndeclaredThrowableException in TaskRunner, to allow checked exceptions wrapping in Tasks.
Date Sat, 14 Nov 2015 04:37:26 GMT
ZEST-128 - Added unwinding of UndeclaredThrowableException in TaskRunner, to allow checked
exceptions wrapping in Tasks.


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/8214c84e
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/8214c84e
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/8214c84e

Branch: refs/heads/develop
Commit: 8214c84ec7f8e5481abfc615adea0588b5503d4e
Parents: 02491a3
Author: Niclas Hedhman <niclas@hedhman.org>
Authored: Sat Nov 14 11:15:19 2015 +0800
Committer: Niclas Hedhman <niclas@hedhman.org>
Committed: Sat Nov 14 11:15:19 2015 +0800

----------------------------------------------------------------------
 .../org/apache/zest/library/scheduler/TaskRunner.java     |  7 ++++++-
 .../apache/zest/library/scheduler/schedule/Schedule.java  | 10 +++++-----
 .../library/scheduler/schedule/cron/CronSchedule.java     |  2 +-
 .../library/scheduler/schedule/once/OnceSchedule.java     |  2 +-
 .../scheduler/timeline/TimelineForScheduleConcern.java    |  4 ++--
 5 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/8214c84e/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/TaskRunner.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/TaskRunner.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/TaskRunner.java
index 8beacee..f506129 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/TaskRunner.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/TaskRunner.java
@@ -55,7 +55,12 @@ public class TaskRunner
             }
             catch( RuntimeException ex )
             {
-                schedule.taskCompletedWithException( ex );
+                Throwable exception = ex;
+                while(exception instanceof UndeclaredThrowableException)
+                {
+                    exception = ((UndeclaredThrowableException) ex).getUndeclaredThrowable();
+                }
+                schedule.taskCompletedWithException( exception );
                 schedule.exceptionCounter().set( schedule.exceptionCounter().get() + 1 );
             }
             schedule.executionCounter().set( schedule.executionCounter().get() + 1 );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/8214c84e/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/Schedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/Schedule.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/Schedule.java
index d2da51b..7e9555f 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/Schedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/Schedule.java
@@ -18,14 +18,13 @@
  */
 package org.apache.zest.library.scheduler.schedule;
 
+import org.apache.zest.api.association.Association;
 import org.apache.zest.api.common.UseDefaults;
 import org.apache.zest.api.entity.EntityComposite;
-import org.joda.time.DateTime;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.property.Immutable;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.library.scheduler.Task;
+import org.joda.time.DateTime;
 
 /**
  * Represent the scheduling of a {@link Task}.
@@ -102,9 +101,10 @@ public interface Schedule extends EntityComposite
     /**
      * Called directly after the {@link org.apache.zest.library.scheduler.Task#run()} method
has been completed but
      * threw a RuntimeException.
-     * @param ex
+     * @param ex The execption that was thrown in the Task. If the thrown Exception was an
+     *           {@link java.lang.reflect.UndeclaredThrowableException} then the underlying
exception is passed here.
      */
-    void taskCompletedWithException( RuntimeException ex );
+    void taskCompletedWithException( Throwable ex );
 
     /**
      * Compute the next time this schedule is to be run.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/8214c84e/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
index d137cb3..9036592 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
@@ -56,7 +56,7 @@ public interface CronSchedule
         }
 
         @Override
-        public void taskCompletedWithException( RuntimeException ex )
+        public void taskCompletedWithException( Throwable ex )
         {
             running().set(false);
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/8214c84e/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
index 66fdb21..ca31cf4 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
@@ -39,7 +39,7 @@ public interface OnceSchedule
         }
 
         @Override
-        public void taskCompletedWithException( RuntimeException ex )
+        public void taskCompletedWithException( Throwable ex )
         {
             running().set( false );
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/8214c84e/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
index ff67025..6bb5c3e 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
@@ -53,7 +53,7 @@ public abstract class TimelineForScheduleConcern
     }
 
     @Override
-    public void taskCompletedWithException( RuntimeException ex )
+    public void taskCompletedWithException( Throwable ex )
     {
         TimelineRecordStep step = TimelineRecordStep.FAILURE;
         String details = "Exception occurred:" + getStackTrace( ex );
@@ -78,7 +78,7 @@ public abstract class TimelineForScheduleConcern
         state.history().set( timelineRecords );
     }
 
-    private String getStackTrace( RuntimeException ex )
+    private String getStackTrace( Throwable ex )
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream( 1000 );
         BufferedOutputStream out = new BufferedOutputStream( baos );


Mime
View raw message