deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject git commit: DELTASPIKE-590 ExceptionHandlerBroadcaster should not rethrow exceptions from BridgeExceptionHandlerWrapper
Date Sun, 11 May 2014 10:46:56 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 834d742c2 -> ebb464d20


DELTASPIKE-590 ExceptionHandlerBroadcaster should not rethrow exceptions from BridgeExceptionHandlerWrapper

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/ebb464d2
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/ebb464d2
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/ebb464d2

Branch: refs/heads/master
Commit: ebb464d20e0dbdaf4b5db0713f3d886cfcf0096e
Parents: 834d742
Author: tandraschko <tandraschko@apache.org>
Authored: Sun May 11 12:46:43 2014 +0200
Committer: tandraschko <tandraschko@apache.org>
Committed: Sun May 11 12:46:43 2014 +0200

----------------------------------------------------------------------
 .../control/event/ExceptionToCatchEvent.java         | 15 ++++++++++++++-
 .../control/ExceptionHandlerBroadcaster.java         |  2 +-
 .../control/BridgeExceptionHandlerWrapper.java       |  6 +++---
 3 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ebb464d2/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/event/ExceptionToCatchEvent.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/event/ExceptionToCatchEvent.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/event/ExceptionToCatchEvent.java
index 96d29e1..c134645 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/event/ExceptionToCatchEvent.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/event/ExceptionToCatchEvent.java
@@ -39,6 +39,7 @@ public class ExceptionToCatchEvent implements Serializable
     private Throwable exception;
     private boolean handled;
     private transient Set<Annotation> qualifiers;
+    private boolean optional;
 
     /**
      * Constructor that adds qualifiers for the handler(s) to run.
@@ -52,6 +53,7 @@ public class ExceptionToCatchEvent implements Serializable
         this.exception = exception;
         this.qualifiers = new HashSet<Annotation>();
         Collections.addAll(this.qualifiers, qualifiers);
+        this.optional = false;
     }
 
     /**
@@ -62,7 +64,8 @@ public class ExceptionToCatchEvent implements Serializable
     public ExceptionToCatchEvent(Throwable exception)
     {
         this.exception = exception;
-        qualifiers = Collections.emptySet();
+        this.qualifiers = Collections.emptySet();
+        this.optional = false;
     }
 
     public Throwable getException()
@@ -99,4 +102,14 @@ public class ExceptionToCatchEvent implements Serializable
     {
         return Collections.unmodifiableSet(qualifiers);
     }
+
+    public boolean isOptional()
+    {
+        return optional;
+    }
+
+    public void setOptional(boolean optional)
+    {
+        this.optional = optional;
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ebb464d2/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerBroadcaster.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerBroadcaster.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerBroadcaster.java
index 9b8e6f4..ab07d5a 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerBroadcaster.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerBroadcaster.java
@@ -189,7 +189,7 @@ public class ExceptionHandlerBroadcaster
                 stack.skipCause();
             }
 
-            if (!exceptionEventEvent.isHandled() && throwException == null)
+            if (!exceptionEventEvent.isHandled() && throwException == null &&
!exceptionEventEvent.isOptional())
             {
                 LOG.warning(String.format("No handlers found for exception %s", exceptionEventEvent.getException()));
                 throw exceptionEventEvent.getException();

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ebb464d2/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/exception/control/BridgeExceptionHandlerWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/exception/control/BridgeExceptionHandlerWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/exception/control/BridgeExceptionHandlerWrapper.java
index 59b5ceb..cf33bdd 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/exception/control/BridgeExceptionHandlerWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/exception/control/BridgeExceptionHandlerWrapper.java
@@ -33,7 +33,6 @@ import javax.faces.event.PhaseId;
 import javax.faces.event.SystemEvent;
 
 import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent;
-import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
 import org.apache.deltaspike.core.spi.activation.Deactivatable;
 
 public class BridgeExceptionHandlerWrapper extends ExceptionHandlerWrapper implements Deactivatable
@@ -72,14 +71,13 @@ public class BridgeExceptionHandlerWrapper extends ExceptionHandlerWrapper
imple
         {
             Iterator<ExceptionQueuedEvent> iterator = exceptionQueuedEvents.iterator();
 
-            BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
-
             while (iterator.hasNext())
             {
                 Throwable throwable = iterator.next().getContext().getException();
                 Throwable rootCause = getRootCause(throwable);
 
                 ExceptionToCatchEvent event = new ExceptionToCatchEvent(rootCause, exceptionQualifier);
+                event.setOptional(true);
 
                 beanManager.fireEvent(event);
 
@@ -127,6 +125,8 @@ public class BridgeExceptionHandlerWrapper extends ExceptionHandlerWrapper
imple
                 Throwable exception = getRootCause(exceptionQueuedEvent.getContext().getException());
 
                 ExceptionToCatchEvent exceptionToCatchEvent = new ExceptionToCatchEvent(exception);
+                exceptionToCatchEvent.setOptional(true);
+
                 this.beanManager.fireEvent(exceptionToCatchEvent);
 
                 if (exceptionToCatchEvent.isHandled())


Mime
View raw message