From: markt Date: Thu, 11 Mar 2010 20:28:34 +0000 (+0000) Subject: Alternative fix for bug 48795. Add a new property to control if the next request... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0b94b4c50cd384eae2b05bada28033a86567e1dc;p=tomcat7.0 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 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@922010 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/conf/web.xml b/conf/web.xml index 3db15fd40..a61ab2475 100644 --- a/conf/web.xml +++ b/conf/web.xml @@ -194,6 +194,14 @@ + + + + + + + + diff --git a/java/org/apache/jasper/EmbeddedServletOptions.java b/java/org/apache/jasper/EmbeddedServletOptions.java index 8284a8cde..3fdb0653a 100644 --- a/java/org/apache/jasper/EmbeddedServletOptions.java +++ b/java/org/apache/jasper/EmbeddedServletOptions.java @@ -170,6 +170,11 @@ public final class EmbeddedServletOptions implements Options { 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 EmbeddedServletOptions implements Options { } /** + * 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 EmbeddedServletOptions implements Options { } } + 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")) { diff --git a/java/org/apache/jasper/JspC.java b/java/org/apache/jasper/JspC.java index d524df551..afca8cf9a 100644 --- a/java/org/apache/jasper/JspC.java +++ b/java/org/apache/jasper/JspC.java @@ -520,6 +520,16 @@ public class JspC implements Options { return 0; } + + /** + * In JspC this always returns false. + * {@inheritDoc} + */ + public boolean getRecompileOnFail() { + return false; + } + + /** * In JspC this always returns false. * {@inheritDoc} diff --git a/java/org/apache/jasper/JspCompilationContext.java b/java/org/apache/jasper/JspCompilationContext.java index a3a8a4ac1..31fcf4a7b 100644 --- a/java/org/apache/jasper/JspCompilationContext.java +++ b/java/org/apache/jasper/JspCompilationContext.java @@ -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( diff --git a/java/org/apache/jasper/Options.java b/java/org/apache/jasper/Options.java index aa0c1c070..fcf011ced 100644 --- a/java/org/apache/jasper/Options.java +++ b/java/org/apache/jasper/Options.java @@ -197,6 +197,12 @@ public interface Options { */ public int getModificationTestInterval(); + + /** + * Re-compile on failure. + */ + public boolean getRecompileOnFail(); + /** * Is caching enabled (used for precompilation). */ diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index 0ca8b0f0d..409da71f8 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -168,6 +168,7 @@ jsp.warning.mappedFile=Warning: Invalid value for the initParam mappedFile. Will 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\"