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/02/01 01:04:40 UTC
svn commit: r905145 - in /tomcat/trunk/java/org/apache/jasper/compiler:
Generator.java ScriptingVariabler.java
Author: markt
Date: Mon Feb 1 00:04:40 2010
New Revision: 905145
URL: http://svn.apache.org/viewvc?rev=905145&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48616, a regression caused by the fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=42390
The requirement for variable declaration also depends on whether or not a fragment helper has been used for the parent tag (if any). Where such a helper has been used, the variables must be redefined.
Test cases for both bugs and the JSP TCK pass with this patch applied.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
tomcat/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Generator.java?rev=905145&r1=905144&r2=905145&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Mon Feb 1 00:04:40 2010
@@ -167,6 +167,26 @@
return b.toString();
}
+ /**
+ * Finds the <jsp:body> subelement of the given parent node. If not
+ * found, null is returned.
+ */
+ protected static Node.JspBody findJspBody(Node parent) {
+ Node.JspBody result = null;
+
+ Node.Nodes subelements = parent.getBody();
+ for (int i = 0; (subelements != null) && (i < subelements.size()); i++) {
+ Node n = subelements.getNode(i);
+ if (n instanceof Node.JspBody) {
+ result = (Node.JspBody) n;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+
private String createJspId() {
if (this.jspIdPrefix == null) {
StringBuilder sb = new StringBuilder(32);
@@ -971,25 +991,6 @@
}
}
- /**
- * Finds the <jsp:body> subelement of the given parent node. If not
- * found, null is returned.
- */
- private Node.JspBody findJspBody(Node parent) {
- Node.JspBody result = null;
-
- Node.Nodes subelements = parent.getBody();
- for (int i = 0; (subelements != null) && (i < subelements.size()); i++) {
- Node n = subelements.getNode(i);
- if (n instanceof Node.JspBody) {
- result = (Node.JspBody) n;
- break;
- }
- }
-
- return result;
- }
-
@Override
public void visit(Node.ForwardAction n) throws JasperException {
Node.JspAttribute page = n.getPage();
Modified: tomcat/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java?rev=905145&r1=905144&r2=905145&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java Mon Feb 1 00:04:40 2010
@@ -70,7 +70,7 @@
public void visit(Node.CustomTag n) throws JasperException {
setScriptingVars(n, VariableInfo.AT_BEGIN);
setScriptingVars(n, VariableInfo.NESTED);
- new ScriptingVariableVisitor(err).visitBody(n);
+ visitBody(n);
setScriptingVars(n, VariableInfo.AT_END);
}
@@ -86,9 +86,9 @@
Vector<Object> vec = new Vector<Object>();
Integer ownRange = null;
+ Node.CustomTag parent = n.getCustomTagParent();
if (scope == VariableInfo.AT_BEGIN
|| scope == VariableInfo.AT_END) {
- Node.CustomTag parent = n.getCustomTagParent();
if (parent == null)
ownRange = MAX_SCOPE;
else
@@ -107,8 +107,11 @@
String varName = varInfos[i].getVarName();
Integer currentRange = scriptVars.get(varName);
- if (currentRange == null
- || ownRange.compareTo(currentRange) > 0) {
+ // If a fragment helper has been used for the parent tag
+ // the scripting variables always need to be declared
+ if (currentRange == null ||
+ ownRange.compareTo(currentRange) > 0 ||
+ parent != null && isImplemetedAsFragment(parent)) {
scriptVars.put(varName, ownRange);
vec.add(varInfos[i]);
}
@@ -131,8 +134,11 @@
}
Integer currentRange = scriptVars.get(varName);
- if (currentRange == null
- || ownRange.compareTo(currentRange) > 0) {
+ // If a fragment helper has been used for the parent tag
+ // the scripting variables always need to be declared
+ if (currentRange == null ||
+ ownRange.compareTo(currentRange) > 0 ||
+ parent != null && isImplemetedAsFragment(parent)) {
scriptVars.put(varName, ownRange);
vec.add(tagVarInfos[i]);
}
@@ -143,6 +149,22 @@
}
}
+ private static boolean isImplemetedAsFragment(Node.CustomTag n) {
+ // Replicates logic from Generator to determine if a fragment
+ // helper will be used
+ if (n.implementsSimpleTag()) {
+ if (Generator.findJspBody(n) == null) {
+ if (!n.hasEmptyBody()) {
+ return true;
+ }
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+
public static void set(Node.Nodes page, ErrorDispatcher err)
throws JasperException {
page.visit(new CustomTagCounter());
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org