incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r685528 - in /incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp: JspScriptEngineFactory.java jasper/compiler/ErrorDispatcher.java jasper/servlet/JspServletWrapper.java
Date Wed, 13 Aug 2008 12:30:26 GMT
Author: cziegeler
Date: Wed Aug 13 05:30:25 2008
New Revision: 685528

URL: http://svn.apache.org/viewvc?rev=685528&view=rev
Log:
SLING-571 ; Apply patch from Alexander Klimetschek

Modified:
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java?rev=685528&r1=685527&r2=685528&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
(original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
Wed Aug 13 05:30:25 2008
@@ -280,11 +280,31 @@
                 try {
                     callJsp(props, scriptHelper);
                 } catch (Exception e) {
-                    throw new ScriptException(e);
+                    throw new BetterScriptException(e.getMessage(), e);
                 }
             }
             return null;
         }
     }
 
+    /**
+     * Fixes {@link ScriptException} that overwrites the
+     * {@link ScriptException#getMessage()} method to display its own
+     * <code>message</code> instead of the <code>detailMessage</code>
+     * defined in {@link Throwable}. Unfortunately using the constructor
+     * {@link ScriptException#ScriptException(Exception)} does not set the
+     * <code>message</code> member of {@link ScriptException}, which leads to
+     * a message of <code>"null"</code>, effectively supressing the detailed
+     * information of the cause. This class provides a way to do that explicitly
+     * with a new constructor accepting both a message and a causing exception.
+     * 
+     */
+    private static class BetterScriptException extends ScriptException {
+        
+        public BetterScriptException(String message, Exception cause) {
+            super(cause);
+            this.message = message;
+        }
+        
+    }
 }

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java?rev=685528&r1=685527&r2=685528&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java
(original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java
Wed Aug 13 05:30:25 2008
@@ -521,20 +521,25 @@
     public static JavacErrorDetail createJavacError(String fname,
             Node.Nodes page, StringBuffer errMsgBuf, int lineNum,
             JspCompilationContext ctxt) throws JasperException {
-        JavacErrorDetail javacError;
-        // Attempt to map javac error line number to line in JSP page
-        ErrorVisitor errVisitor = new ErrorVisitor(lineNum);
-        page.visit(errVisitor);
-        Node errNode = errVisitor.getJspSourceNode();
-        if ((errNode != null) && (errNode.getStart() != null)) {
-            javacError = new JavacErrorDetail(
-                    fname,
-                    lineNum,
-                    errNode.getStart().getFile(),
-                    errNode.getStart().getLineNumber(),
-                    errMsgBuf,
-                    ctxt);
-        } else {
+        JavacErrorDetail javacError = null;
+        
+        if (page != null) {
+            // Attempt to map javac error line number to line in JSP page
+            ErrorVisitor errVisitor = new ErrorVisitor(lineNum);
+            page.visit(errVisitor);
+            Node errNode = errVisitor.getJspSourceNode();
+            if ((errNode != null) && (errNode.getStart() != null)) {
+                javacError = new JavacErrorDetail(
+                        fname,
+                        lineNum,
+                        errNode.getStart().getFile(),
+                        errNode.getStart().getLineNumber(),
+                        errMsgBuf,
+                        ctxt);
+            }
+        }
+        
+        if (javacError == null) {
             /*
              * javac error line number cannot be mapped to JSP page
              * line number. For example, this is the case if a 

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java?rev=685528&r1=685527&r2=685528&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
(original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
Wed Aug 13 05:30:25 2008
@@ -486,6 +486,10 @@
             Throwable realException = ex;
             if (ex instanceof ServletException) {
                 realException = ((ServletException) ex).getRootCause();
+                // root cause might be null (eg. for a JasperException ex)
+                if (realException == null) {
+                    realException = ex;
+                }
             }
 
             // First identify the stack frame in the trace that represents the JSP



Mime
View raw message