You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/03/11 21:28:34 UTC

svn commit: r922010 - in /tomcat/trunk: conf/ java/org/apache/jasper/ java/org/apache/jasper/resources/

Author: markt
Date: Thu Mar 11 20:28:34 2010
New Revision: 922010

URL: http://svn.apache.org/viewvc?rev=922010&view=rev
Log:
Alternative fix for bug 48795. Add a new property to control if the next request always triggers recompilation after a compilation failure. Defaults to false and only applies in development mode

Modified:
    tomcat/trunk/conf/web.xml
    tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java
    tomcat/trunk/java/org/apache/jasper/JspC.java
    tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
    tomcat/trunk/java/org/apache/jasper/Options.java
    tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties

Modified: tomcat/trunk/conf/web.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/conf/web.xml?rev=922010&r1=922009&r2=922010&view=diff
==============================================================================
--- tomcat/trunk/conf/web.xml (original)
+++ tomcat/trunk/conf/web.xml Thu Mar 11 20:28:34 2010
@@ -194,6 +194,14 @@
   <!--                       to be checked on every access.                 -->
   <!--                       Used in development mode only. [4]             -->
   <!--                                                                      -->
+  <!--   recompileOnFail     If a JSP compilation fails should the          -->
+  <!--                       modificationTestInterval be ignored and the    -->
+  <!--                       next access trigger a re-compilation attempt?  -->
+  <!--                       Used in development mode only and is disabled  -->
+  <!--                       by default as compilation may be expensive and -->
+  <!--                       could lead to excessive resource usage.        -->
+  <!--                       [false]                                        -->
+  <!--                                                                      -->
   <!--   scratchdir          What scratch directory should we use when      -->
   <!--                       compiling JSP pages?  [default work directory  -->
   <!--                       for the current web application]               -->

Modified: tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java?rev=922010&r1=922009&r2=922010&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java (original)
+++ tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java Thu Mar 11 20:28:34 2010
@@ -170,6 +170,11 @@ public final class EmbeddedServletOption
     private int modificationTestInterval = 4;
     
     /**
+     * Is re-compilation attempted immediately after a failure?
+     */
+    private boolean recompileOnFail = false;
+    
+    /**
      * Is generation of X-Powered-By response header enabled/disabled?
      */
     private boolean xpoweredBy;
@@ -238,6 +243,13 @@ public final class EmbeddedServletOption
     }
     
     /**
+     * Re-compile on failure.
+     */
+    public boolean getRecompileOnFail() {
+        return recompileOnFail;
+    }
+    
+    /**
      * Is Jasper being used in development mode?
      */
     public boolean getDevelopment() {
@@ -477,6 +489,18 @@ public final class EmbeddedServletOption
             }
         }
         
+        String recompileOnFail = config.getInitParameter("recompileOnFail"); 
+        if (recompileOnFail != null) {
+            if (recompileOnFail.equalsIgnoreCase("true")) {
+                this.recompileOnFail = true;
+            } else if (recompileOnFail.equalsIgnoreCase("false")) {
+                this.recompileOnFail = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.recompileOnFail"));
+                }
+            }
+        }
         String development = config.getInitParameter("development");
         if (development != null) {
             if (development.equalsIgnoreCase("true")) {

Modified: tomcat/trunk/java/org/apache/jasper/JspC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspC.java?rev=922010&r1=922009&r2=922010&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspC.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspC.java Thu Mar 11 20:28:34 2010
@@ -520,6 +520,16 @@ public class JspC implements Options {
         return 0;
     }
 
+
+    /**
+     * In JspC this always returns <code>false</code>.
+     * {@inheritDoc}
+     */
+    public boolean getRecompileOnFail() {
+        return false;
+    }
+    
+    
     /**
      * In JspC this always returns <code>false</code>.
      * {@inheritDoc}

Modified: tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java?rev=922010&r1=922009&r2=922010&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java Thu Mar 11 20:28:34 2010
@@ -595,6 +595,10 @@ public class JspCompilationContext {
             } catch (JasperException ex) {
                 // Cache compilation exception
                 jsw.setCompilationException(ex);
+                if (options.getDevelopment() && options.getRecompileOnFail()) {
+                    // Force a recompilation attempt on next access
+                    jsw.setLastModificationTest(-1);
+                }
                 throw ex;
             } catch (Exception ex) {
                 JasperException je = new JasperException(

Modified: tomcat/trunk/java/org/apache/jasper/Options.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/Options.java?rev=922010&r1=922009&r2=922010&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/Options.java (original)
+++ tomcat/trunk/java/org/apache/jasper/Options.java Thu Mar 11 20:28:34 2010
@@ -197,6 +197,12 @@ public interface Options {
      */
     public int getModificationTestInterval();
     
+
+    /**
+     * Re-compile on failure.
+     */
+    public boolean getRecompileOnFail();
+    
     /**
      * Is caching enabled (used for precompilation).
      */

Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=922010&r1=922009&r2=922010&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Thu Mar 11 20:28:34 2010
@@ -168,6 +168,7 @@ jsp.warning.mappedFile=Warning: Invalid 
 jsp.warning.classDebugInfo=Warning: Invalid value for the initParam classdebuginfo. Will use the default value of \"false\"
 jsp.warning.checkInterval=Warning: Invalid value for the initParam checkInterval. Will use the default value of \"300\" seconds
 jsp.warning.modificationTestInterval=Warning: Invalid value for the initParam modificationTestInterval. Will use the default value of \"4\" seconds
+jsp.warning.recompileOnFail=Warning: Invalid value for the initParam recompileOnFail. Will use the default value of \"false\"
 jsp.warning.development=Warning: Invalid value for the initParam development. Will use the default value of \"true\"
 jsp.warning.fork=Warning: Invalid value for the initParam fork. Will use the default value of \"true\"
 jsp.warning.reloading=Warning: Invalid value for the initParam reloading. Will use the default value of \"true\"



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