tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1201546 - in /tomcat/trunk/java/org/apache/jasper: runtime/TagHandlerPool.java servlet/JspServletWrapper.java tagplugins/jstl/core/Set.java
Date Sun, 13 Nov 2011 23:39:26 GMT
Author: kkolinko
Date: Sun Nov 13 23:39:25 2011
New Revision: 1201546

URL: http://svn.apache.org/viewvc?rev=1201546&view=rev
Log:
Improve processing of errors that are wrapped into InvocationTargetException.
Rethrow errors that must be rethrown.

Modified:
    tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
    tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
    tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java

Modified: tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java?rev=1201546&r1=1201545&r2=1201546&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java (original)
+++ tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java Sun Nov 13 23:39:25 2011
@@ -22,6 +22,7 @@ import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.Tag;
 
 import org.apache.jasper.Constants;
+import org.apache.jasper.util.ExceptionUtils;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
@@ -121,7 +122,9 @@ public class TagHandlerPool {
                 return instance;
             }
         } catch (Exception e) {
-            throw new JspException(e.getMessage(), e);
+            Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
+            ExceptionUtils.handleThrowable(t);
+            throw new JspException(e.getMessage(), t);
         }
     }
 
@@ -145,8 +148,10 @@ public class TagHandlerPool {
         try {
             instanceManager.destroyInstance(handler);
         } catch (Exception e) {
+            Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
+            ExceptionUtils.handleThrowable(t);
             log.warn("Error processing preDestroy on tag instance of " +
-                    handler.getClass().getName(), e);
+                    handler.getClass().getName(), t);
         }
     }
 
@@ -156,12 +161,15 @@ public class TagHandlerPool {
      */
     public synchronized void release() {
         for (int i = current; i >= 0; i--) {
-            handlers[i].release();
+            Tag handler = handlers[i];
+            handler.release();
             try {
-                instanceManager.destroyInstance(handlers[i]);
+                instanceManager.destroyInstance(handler);
             } catch (Exception e) {
-                log.warn("Error processing preDestroy on tag instance of " +
-                        handlers[i].getClass().getName(), e);
+                Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
+                ExceptionUtils.handleThrowable(t);
+                log.warn("Error processing preDestroy on tag instance of "
+                        + handler.getClass().getName(), t);
             }
         }
     }

Modified: tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java?rev=1201546&r1=1201545&r2=1201546&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java (original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java Sun Nov 13 23:39:25
2011
@@ -170,12 +170,11 @@ public class JspServletWrapper {
                     try {
                         InstanceManager instanceManager = InstanceManagerFactory.getInstanceManager(config);
                         servlet = (Servlet) instanceManager.newInstance(ctxt.getFQCN(), ctxt.getJspLoader());
-                    } catch (IllegalAccessException e) {
-                        throw new JasperException(e);
-                    } catch (InstantiationException e) {
-                        throw new JasperException(e);
                     } catch (Exception e) {
-                        throw new JasperException(e);
+                        Throwable t = ExceptionUtils
+                                .unwrapInvocationTargetException(e);
+                        ExceptionUtils.handleThrowable(t);
+                        throw new JasperException(t);
                     }
 
                     servlet.init(config);
@@ -481,9 +480,11 @@ public class JspServletWrapper {
             try {
                 instanceManager.destroyInstance(theServlet);
             } catch (Exception e) {
+                Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
+                ExceptionUtils.handleThrowable(t);
                 // Log any exception, since it can't be passed along
                 log.error(Localizer.getMessage("jsp.error.file.not.found",
-                        e.getMessage()), e);
+                        e.getMessage()), t);
             }
         }
     }

Modified: tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java?rev=1201546&r1=1201545&r2=1201546&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java (original)
+++ tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java Sun Nov 13 23:39:25
2011
@@ -156,6 +156,12 @@ public class Set implements TagPlugin {
             ctxt.generateJavaSource("        } catch (java.beans.IntrospectionException ex)
{");
             ctxt.generateJavaSource("            throw new JspException(ex);");
             ctxt.generateJavaSource("        } catch (java.lang.reflect.InvocationTargetException
ex) {");
+            ctxt.generateJavaSource("            if (ex.getCause() instanceof ThreadDeath)
{");
+            ctxt.generateJavaSource("                throw (ThreadDeath) ex.getCause();");
+            ctxt.generateJavaSource("            }");
+            ctxt.generateJavaSource("            if (ex.getCause() instanceof VirtualMachineError)
{");
+            ctxt.generateJavaSource("                throw (VirtualMachineError) ex.getCause();");
+            ctxt.generateJavaSource("            }");
             ctxt.generateJavaSource("            throw new JspException(ex);");
             ctxt.generateJavaSource("        }");
             ctxt.generateJavaSource("    }");



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message