click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r785786 - in /incubator/click/trunk/click/framework/src/org/apache/click: ClickRequestWrapper.java ClickServlet.java Context.java
Date Wed, 17 Jun 2009 20:43:05 GMT
Author: sabob
Date: Wed Jun 17 20:43:05 2009
New Revision: 785786

URL: http://svn.apache.org/viewvc?rev=785786&view=rev
Log:
fixed ClickServlet to handle Context.CONTEXT_FATAL_ERROR which could be any Throwable, not
just Exception

Modified:
    incubator/click/trunk/click/framework/src/org/apache/click/ClickRequestWrapper.java
    incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java
    incubator/click/trunk/click/framework/src/org/apache/click/Context.java

Modified: incubator/click/trunk/click/framework/src/org/apache/click/ClickRequestWrapper.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/ClickRequestWrapper.java?rev=785786&r1=785785&r2=785786&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/ClickRequestWrapper.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/ClickRequestWrapper.java Wed
Jun 17 20:43:05 2009
@@ -120,9 +120,9 @@
 
             } catch (Throwable t) {
 
-                // Don't throw exception here as it will break Context creation.
-                // Instead add the exception as a request attribute.
-                request.setAttribute(Context.CONTEXT_FATAL_EXCEPTION, t);
+                // Don't throw error here as it will break Context creation.
+                // Instead add the error as a request attribute.
+                request.setAttribute(Context.CONTEXT_FATAL_ERROR, t);
 
             } finally {
                 fileItemMap = Collections.unmodifiableMap(fileItems);

Modified: incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java?rev=785786&r1=785785&r2=785786&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/ClickServlet.java Wed Jun 17
20:43:05 2009
@@ -307,23 +307,31 @@
         Page page = null;
         try {
 
+            ActionEventDispatcher eventDispatcher = createActionEventDispatcher();
+            // Bind ActionEventDispatcher to current thread
+            ActionEventDispatcher.pushThreadLocalDispatcher(eventDispatcher);
+
             Context context = createContext(request, response, isPost);
             // Bind context to current thread
             Context.pushThreadLocalContext(context);
 
-            // Check for fatal exception that occurred while creating Context
-            Exception exception = (Exception)
-                request.getAttribute(Context.CONTEXT_FATAL_EXCEPTION);
+            // Check for fatal error that occurred while creating Context
+            Throwable error = (Throwable) request.getAttribute(Context.CONTEXT_FATAL_ERROR);
 
-            if (exception != null) {
+            if (error != null) {
                 // Process exception through Click's exception handler.
-                throw exception;
+                if (error instanceof Exception) {
+                    throw (Exception) error;
+                }
+                // Errors are not handled by Click, let the server handle it
+                if (error instanceof Error) {
+                    throw (Error) error;
+                } else {
+                    // Throwables are not handled by Click, let the server handle it
+                    throw new RuntimeException(error);
+                }
             }
 
-            ActionEventDispatcher eventDispatcher = createActionEventDispatcher();
-            // Bind ActionEventDispatcher to current thread
-            ActionEventDispatcher.pushThreadLocalDispatcher(eventDispatcher);
-
             page = createPage(request);
 
             if (page.isStateful()) {

Modified: incubator/click/trunk/click/framework/src/org/apache/click/Context.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/Context.java?rev=785786&r1=785785&r2=785786&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/Context.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/Context.java Wed Jun 17 20:43:05
2009
@@ -57,10 +57,10 @@
     public static final String LOCALE = "locale";
 
     /**
-     * The attribute key used for storing a fatal exception that occurred while
+     * The attribute key used for storing any error that occurred while
      * Context is created.
      */
-    static final String CONTEXT_FATAL_EXCEPTION = "_context_fatal_exception";
+    static final String CONTEXT_FATAL_ERROR = "_context_fatal_error";
 
     /** The thread local context. */
     private static final ThreadLocal THREAD_LOCAL_CONTEXT = new ThreadLocal();



Mime
View raw message