Re: svn commit: r1503857 - in /tomcat/trunk: java/javax/el/ java/org/apache/el/parser/ test/org/apache/el/parser/

2013-07-17 Thread Violeta Georgieva
2013/7/16 
>
> Author: markt
> Date: Tue Jul 16 20:01:47 2013
> New Revision: 1503857
>
> URL: http://svn.apache.org/r1503857
> Log:
> Fix handling of nested lambda expressions with method parameters.
>
> Removed:
>
tomcat/trunk/java/org/apache/el/parser/AstLambdaExpressionOrInvocation.java
> Modified:
> tomcat/trunk/java/javax/el/LambdaExpression.java
> tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
> tomcat/trunk/java/org/apache/el/parser/ELParser.java
> tomcat/trunk/java/org/apache/el/parser/ELParser.jjt
> tomcat/trunk/java/org/apache/el/parser/ELParserTreeConstants.java
> tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java
>
> Modified: tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
> URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java?rev=1503857&r1=1503856&r2=1503857&view=diff
>
==
> --- tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
(original)
> +++ tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java Tue
Jul 16 20:01:47 2013
> @@ -35,11 +35,15 @@ public class AstLambdaExpression extends
>  @Override
>  public Object getValue(EvaluationContext ctx) throws ELException {
>
> -// Two children - the formal parameters and the expression
> +// First child is always parameters even if there aren't any
>  AstLambdaParameters formalParametersNode =
>  (AstLambdaParameters) children[0];
>  Node[] formalParamNodes = formalParametersNode.children;
>
> +// Second child is a value expression
> +ValueExpressionImpl ve = new ValueExpressionImpl("", children[1],
> +ctx.getFunctionMapper(), ctx.getVariableMapper(), null);
> +
>  // Build a LambdaExpression
>  List formalParameters = new ArrayList<>();
>  if (formalParamNodes != null) {
> @@ -47,30 +51,29 @@ public class AstLambdaExpression extends
>  formalParameters.add(formalParamNode.getImage());
>  }
>  }
> -
> -ValueExpressionImpl ve = new ValueExpressionImpl("", children[1],
> -ctx.getFunctionMapper(), ctx.getVariableMapper(), null);
>  LambdaExpression le = new LambdaExpression(formalParameters, ve);
>  le.setELContext(ctx);
>
>  if (formalParameters.isEmpty()) {
> -// No formal parameters - should be able to simply invoke
this
> +// No formal parameters - invoke the expression
>  return le.invoke(ctx, (Object[]) null);
> -} else {
> -// Has parameters but they aren't provided so return the
> -// LambdaExpression
> -return le;
>  }
> -}
>
> -@Override
> -public Object invoke(EvaluationContext ctx, Class[] paramTypes,
> -Object[] paramValues) throws ELException {
> -
> -Object result = getValue(ctx);
> +// If there are method parameters, need to invoke the expression
with
> +// those parameters. If there are multiple method parameters
there
> +// should be that many nested expressions.
> +// If there are more nested expressions that parameters this
will return
> +// a LambdaExpression
> +Object result = le;
> +int i = 2;
> +while (result instanceof LambdaExpression && i <
jjtGetNumChildren()) {
> +result = ((LambdaExpression) result).invoke(
> +((AstMethodParameters)
children[i]).getParameters(ctx));
> +i++;
> +}
>
> -if (result instanceof LambdaExpression) {
> -result = ((LambdaExpression) result).invoke(ctx,
paramValues);
> +if (i < jjtGetNumChildren()) {
> +throw new ELException();
>  }
>
>  return result;


Having the example from the test:
(x->y->x-y)(2)(1)

We may transform it like this:
(()->y->2-y)()(1)

So instead of returning right way when formalParameters.isEmpty()

Shouldn't we have something like the one below in order to continue
evaluation of the nested expression:



--- org/apache/el/parser/AstLambdaExpression.java (revision 1504024)
+++ org/apache/el/parser/AstLambdaExpression.java (working copy)
@@ -54,9 +54,12 @@
 LambdaExpression le = new LambdaExpression(formalParameters, ve);
 le.setELContext(ctx);

+Object result = le;
+int i = 2;
 if (formalParameters.isEmpty()) {
 // No formal parameters - invoke the expression
-return le.invoke(ctx, (Object[]) null);
+result = ((LambdaExpression) result).invoke(ctx, (Object[])
null);
+i++;
 }

 // If there are method parameters, need to invoke the expression
with
@@ -64,8 +67,6 @@
 // should be that many nested expressions.
 // If there are more nested expressions that parameters this

Re: svn commit: r1503857 - in /tomcat/trunk: java/javax/el/ java/org/apache/el/parser/ test/org/apache/el/parser/

2013-07-17 Thread Mark Thomas
Violeta Georgieva  wrote:

>Having the example from the test:
>(x->y->x-y)(2)(1)
>
>We may transform it like this:
>(()->y->2-y)()(1)
>
>So instead of returning right way when formalParameters.isEmpty()
>
>Shouldn't we have something like the one below in order to continue
>evaluation of the nested expression:
>
>
>
>--- org/apache/el/parser/AstLambdaExpression.java (revision 1504024)
>+++ org/apache/el/parser/AstLambdaExpression.java (working copy)
>@@ -54,9 +54,12 @@
>  LambdaExpression le = new LambdaExpression(formalParameters, ve);
> le.setELContext(ctx);
>
>+Object result = le;
>+int i = 2;
> if (formalParameters.isEmpty()) {
> // No formal parameters - invoke the expression
>-return le.invoke(ctx, (Object[]) null);
>+result = ((LambdaExpression) result).invoke(ctx,
>(Object[])
>null);
>+i++;
> }
>
>   // If there are method parameters, need to invoke the expression
>with
>@@ -64,8 +67,6 @@
> // should be that many nested expressions.
>  // If there are more nested expressions that parameters this will
>return
> // a LambdaExpression
>-Object result = le;
>-int i = 2;
> while (result instanceof LambdaExpression && i <
>jjtGetNumChildren()) {
> result = ((LambdaExpression) result).invoke(
> ((AstMethodParameters)
>children[i]).getParameters(ctx));

I agree the current solution isn't right but I have some local test cases that 
I'm fairly sure will still fail with the above patch. I'm working on a fix and 
should have something to commit soon.

Mark


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



Re: Various shell-scripting idioms in bin/daemon.sh

2013-07-17 Thread Mladen Turk

On 07/16/2013 11:42 PM, Christopher Schultz wrote:

All,

While doing the trivial fix for
https://issues.apache.org/bugzilla/show_bug.cgi?id=55268, I noticed a
few idioms being used in bin/daemon.sh that struck me as odd. For example:

while [ ".$1" != . ]
do
   case "$1" in
 --java-home )
 JAVA_HOME="$2"
 shift; shift;
 continue
 ;;


This example actually illustrates the two main questions I had:

1. Why use [ ".$FOO" != . ] instead of simply [ -n "$FOO" ] (Corollary:
why use [ ".$FOO" = . ] instead of [ -z "$FOO" ])?



Because some shell scripts does dot handle -z or -n well.


2. Why have a "continue" at the end of every case option, since the
whole body of the while loop is nothing but the case construct?



That might be an extra directive, true.
Probably a leftover from multiple case directives in while loop.



I may be spoiled by using Linux and bash for most of my career, but I
believe these are fairly standard POSIX-compliant things that should
work on all *NIX systems.



Sadly that's not the case IMHO.


Regards
--
^TM

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



svn commit: r1504123 - in /tomcat/trunk: java/org/apache/el/Messages.properties java/org/apache/el/parser/AstLambdaExpression.java test/org/apache/el/parser/TestAstLambdaExpression.java

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 13:24:09 2013
New Revision: 1504123

URL: http://svn.apache.org/r1504123
Log:
Further improve handling of nested lambda expressions.

Modified:
tomcat/trunk/java/org/apache/el/Messages.properties
tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java

Modified: tomcat/trunk/java/org/apache/el/Messages.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/Messages.properties?rev=1504123&r1=1504122&r2=1504123&view=diff
==
--- tomcat/trunk/java/org/apache/el/Messages.properties (original)
+++ tomcat/trunk/java/org/apache/el/Messages.properties Wed Jul 17 13:24:09 2013
@@ -52,3 +52,4 @@ error.context.null=ELContext was null
 
 # Parser
 error.identifier.notjava=The identifier [{0}] is not a valid Java identifier 
as required by section 1.19 of the EL specification (Identifier ::= Java 
language identifier). This check can be disabled by setting the system property 
org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.
+error.lambda.tooManyMethodParameterSets=There are more sets of method 
parameters specified than there are nested lambda expressions

Modified: tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java?rev=1504123&r1=1504122&r2=1504123&view=diff
==
--- tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java Wed Jul 17 
13:24:09 2013
@@ -25,6 +25,7 @@ import javax.el.LambdaExpression;
 
 import org.apache.el.ValueExpressionImpl;
 import org.apache.el.lang.EvaluationContext;
+import org.apache.el.util.MessageFactory;
 
 public class AstLambdaExpression extends SimpleNode {
 
@@ -35,6 +36,24 @@ public class AstLambdaExpression extends
 @Override
 public Object getValue(EvaluationContext ctx) throws ELException {
 
+// Check that there are not more sets of method parameters than there
+// are nested lambda expressions
+int methodParameterSetCount = jjtGetNumChildren() - 2;
+if (methodParameterSetCount > 0) {
+// We know this node is an expression
+methodParameterSetCount--;
+Node n = this.jjtGetChild(1);
+while (methodParameterSetCount > 0) {
+if (n.jjtGetNumChildren() <2 ||
+!(n.jjtGetChild(0) instanceof AstLambdaParameters)) {
+throw new ELException(MessageFactory.get(
+"error.lambda.tooManyMethodParameterSets"));
+}
+n = n.jjtGetChild(1);
+methodParameterSetCount--;
+}
+}
+
 // First child is always parameters even if there aren't any
 AstLambdaParameters formalParametersNode =
 (AstLambdaParameters) children[0];
@@ -54,16 +73,22 @@ public class AstLambdaExpression extends
 LambdaExpression le = new LambdaExpression(formalParameters, ve);
 le.setELContext(ctx);
 
-if (formalParameters.isEmpty()) {
+if (formalParameters.isEmpty() && jjtGetNumChildren() == 2) {
 // No formal parameters - invoke the expression
 return le.invoke(ctx, (Object[]) null);
 }
 
 // If there are method parameters, need to invoke the expression with
-// those parameters. If there are multiple method parameters there
-// should be that many nested expressions.
-// If there are more nested expressions that parameters this will 
return
-// a LambdaExpression
+// those parameters. If there are multiple sets of method parameters
+// there should be at least that many nested expressions.
+// If there are more nested expressions than sets of method parameters
+// this may return a LambdaExpression.
+// If there are more sets of method parameters than nested expressions
+// an ELException will have been thrown by the check at the start of
+// this method.
+// If the inner most expression(s) do not require parameters then a
+// value will be returned once the outermost expression that does
+// require a parameter has been evaluated.
 Object result = le;
 int i = 2;
 while (result instanceof LambdaExpression && i < jjtGetNumChildren()) {
@@ -72,10 +97,6 @@ public class AstLambdaExpression extends
 i++;
 }
 
-if (i < jjtGetNumChildren()) {
-throw new ELException();
-}
-
 return result;
 }
 }

Modified: tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org

svn commit: r1504124 - /tomcat/trunk/webapps/docs/config/systemprops.xml

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 13:24:30 2013
New Revision: 1504124

URL: http://svn.apache.org/r1504124
Log:
Whitespace police

Modified:
tomcat/trunk/webapps/docs/config/systemprops.xml

Modified: tomcat/trunk/webapps/docs/config/systemprops.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/systemprops.xml?rev=1504124&r1=1504123&r2=1504124&view=diff
==
--- tomcat/trunk/webapps/docs/config/systemprops.xml (original)
+++ tomcat/trunk/webapps/docs/config/systemprops.xml Wed Jul 17 13:24:30 2013
@@ -84,7 +84,7 @@
   Number and Character types and false for Boolean as required
   by the EL 2.2 and earlier specifications. If this property is
   false the result of the coercion will be null 
as
-  required by the EL 3.0 specification. 
+  required by the EL 3.0 specification.
   If not specified, the default value of false will be
   used.
 



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



svn commit: r1504127 - in /tomcat/trunk/java/org/apache/el: Messages.properties stream/Optional.java stream/Stream.java

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 13:28:25 2013
New Revision: 1504127

URL: http://svn.apache.org/r1504127
Log:
Provide messages with exceptions

Modified:
tomcat/trunk/java/org/apache/el/Messages.properties
tomcat/trunk/java/org/apache/el/stream/Optional.java
tomcat/trunk/java/org/apache/el/stream/Stream.java

Modified: tomcat/trunk/java/org/apache/el/Messages.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/Messages.properties?rev=1504127&r1=1504126&r2=1504127&view=diff
==
--- tomcat/trunk/java/org/apache/el/Messages.properties (original)
+++ tomcat/trunk/java/org/apache/el/Messages.properties Wed Jul 17 13:28:25 2013
@@ -53,3 +53,7 @@ error.context.null=ELContext was null
 # Parser
 error.identifier.notjava=The identifier [{0}] is not a valid Java identifier 
as required by section 1.19 of the EL specification (Identifier ::= Java 
language identifier). This check can be disabled by setting the system property 
org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.
 error.lambda.tooManyMethodParameterSets=There are more sets of method 
parameters specified than there are nested lambda expressions
+
+# Stream
+stream.optional.empty=It is illegal to call get() on an empty optional
+stream.compare.notComparable=Stream elements must implement Comparable
\ No newline at end of file

Modified: tomcat/trunk/java/org/apache/el/stream/Optional.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/stream/Optional.java?rev=1504127&r1=1504126&r2=1504127&view=diff
==
--- tomcat/trunk/java/org/apache/el/stream/Optional.java (original)
+++ tomcat/trunk/java/org/apache/el/stream/Optional.java Wed Jul 17 13:28:25 
2013
@@ -19,6 +19,8 @@ package org.apache.el.stream;
 import javax.el.ELException;
 import javax.el.LambdaExpression;
 
+import org.apache.el.util.MessageFactory;
+
 public class Optional {
 
 private final Object obj;
@@ -32,7 +34,7 @@ public class Optional {
 
 public Object get() throws ELException {
 if (obj == null) {
-throw new ELException();
+throw new ELException(MessageFactory.get("stream.optional.empty"));
 } else {
 return obj;
 }

Modified: tomcat/trunk/java/org/apache/el/stream/Stream.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/stream/Stream.java?rev=1504127&r1=1504126&r2=1504127&view=diff
==
--- tomcat/trunk/java/org/apache/el/stream/Stream.java (original)
+++ tomcat/trunk/java/org/apache/el/stream/Stream.java Wed Jul 17 13:28:25 2013
@@ -30,6 +30,7 @@ import javax.el.LambdaExpression;
 
 import org.apache.el.lang.ELArithmetic;
 import org.apache.el.lang.ELSupport;
+import org.apache.el.util.MessageFactory;
 
 public class Stream {
 
@@ -412,7 +413,8 @@ public class Stream {
 if ((obj instanceof Comparable)) {
 result = (Comparable) obj;
 } else {
-throw new ELException();
+throw new ELException(
+MessageFactory.get("stream.compare.notComparable"));
 }
 }
 
@@ -425,7 +427,8 @@ public class Stream {
 result = (Comparable) obj;
 }
 } else {
-throw new ELException();
+throw new ELException(
+MessageFactory.get("stream.compare.notComparable"));
 }
 }
 



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



Re: svn commit: r1503857 - in /tomcat/trunk: java/javax/el/ java/org/apache/el/parser/ test/org/apache/el/parser/

2013-07-17 Thread Mark Thomas
On 17/07/2013 12:43, Mark Thomas wrote:
> Violeta Georgieva  wrote:
> 
>> Having the example from the test:
>> (x->y->x-y)(2)(1)
>>
>> We may transform it like this:
>> (()->y->2-y)()(1)
>>
>> So instead of returning right way when formalParameters.isEmpty()
>>
>> Shouldn't we have something like the one below in order to continue
>> evaluation of the nested expression:
>>
>>
>>
>> --- org/apache/el/parser/AstLambdaExpression.java (revision 1504024)
>> +++ org/apache/el/parser/AstLambdaExpression.java (working copy)
>> @@ -54,9 +54,12 @@
>>  LambdaExpression le = new LambdaExpression(formalParameters, ve);
>> le.setELContext(ctx);
>>
>> +Object result = le;
>> +int i = 2;
>> if (formalParameters.isEmpty()) {
>> // No formal parameters - invoke the expression
>> -return le.invoke(ctx, (Object[]) null);
>> +result = ((LambdaExpression) result).invoke(ctx,
>> (Object[])
>> null);
>> +i++;
>> }
>>
>>   // If there are method parameters, need to invoke the expression
>> with
>> @@ -64,8 +67,6 @@
>> // should be that many nested expressions.
>>  // If there are more nested expressions that parameters this will
>> return
>> // a LambdaExpression
>> -Object result = le;
>> -int i = 2;
>> while (result instanceof LambdaExpression && i <
>> jjtGetNumChildren()) {
>> result = ((LambdaExpression) result).invoke(
>> ((AstMethodParameters)
>> children[i]).getParameters(ctx));
> 
> I agree the current solution isn't right but I have some local test cases 
> that I'm fairly sure will still fail with the above patch. I'm working on a 
> fix and should have something to commit soon.

Fix applied. What do you think?

Mark


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



Re: Various shell-scripting idioms in bin/daemon.sh

2013-07-17 Thread sebb
On 17 July 2013 12:59, Mladen Turk  wrote:
> On 07/16/2013 11:42 PM, Christopher Schultz wrote:
>>
>> All,
>>
>> While doing the trivial fix for
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=55268, I noticed a
>> few idioms being used in bin/daemon.sh that struck me as odd. For example:
>>
>> while [ ".$1" != . ]
>> do
>>case "$1" in
>>  --java-home )
>>  JAVA_HOME="$2"
>>  shift; shift;
>>  continue
>>  ;;
>>
>>
>> This example actually illustrates the two main questions I had:
>>
>> 1. Why use [ ".$FOO" != . ] instead of simply [ -n "$FOO" ] (Corollary:
>> why use [ ".$FOO" = . ] instead of [ -z "$FOO" ])?
>>
>
> Because some shell scripts does dot handle -z or -n well.
>
>
>> 2. Why have a "continue" at the end of every case option, since the
>> whole body of the while loop is nothing but the case construct?
>>
>
> That might be an extra directive, true.
> Probably a leftover from multiple case directives in while loop.
>

But safer than forgetting to add the continue if another case is ever added.

>
>
>> I may be spoiled by using Linux and bash for most of my career, but I
>> believe these are fairly standard POSIX-compliant things that should
>> work on all *NIX systems.
>>
>
> Sadly that's not the case IMHO.

May I suggest a short comment is added to the script to document why
-z and -n are not used?
Someone else reading the script in the future is going to wonder the same.

>
> Regards
> --
> ^TM
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

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



svn commit: r1504148 - in /tomcat/trunk: java/org/apache/jasper/compiler/ java/org/apache/jasper/el/ java/org/apache/jasper/runtime/ test/javax/el/ test/org/apache/el/ test/org/apache/el/parser/ test/

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 14:14:28 2013
New Revision: 1504148

URL: http://svn.apache.org/r1504148
Log:
Add the two new resolver types (stream and static) to Jasper in the correct 
order and modify JasperELResolver so the correct resolvers are skipped.

Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Validator.java
tomcat/trunk/java/org/apache/jasper/el/ELContextImpl.java
tomcat/trunk/java/org/apache/jasper/el/ELResolverImpl.java
tomcat/trunk/java/org/apache/jasper/el/ExpressionEvaluatorImpl.java
tomcat/trunk/java/org/apache/jasper/el/ExpressionImpl.java
tomcat/trunk/java/org/apache/jasper/el/JasperELResolver.java
tomcat/trunk/java/org/apache/jasper/runtime/JspApplicationContextImpl.java
tomcat/trunk/test/javax/el/TestBeanELResolver.java
tomcat/trunk/test/javax/el/TestResourceBundleELResolver.java
tomcat/trunk/test/org/apache/el/TestELEvaluation.java
tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java
tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java
tomcat/trunk/test/org/apache/el/parser/TestELParser.java
tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java
tomcat/trunk/test/org/apache/jasper/el/TestJasperELResolver.java

Modified: tomcat/trunk/java/org/apache/jasper/compiler/Validator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Validator.java?rev=1504148&r1=1504147&r2=1504148&view=diff
==
--- tomcat/trunk/java/org/apache/jasper/compiler/Validator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Validator.java Wed Jul 17 
14:14:28 2013
@@ -1215,7 +1215,8 @@ class Validator {
 attrs.getQName(i), attrs.getURI(i),
 attrs.getLocalName(i),
 attrs.getValue(i), false, el, 
false);
-ELContextImpl ctx = new ELContextImpl();
+ELContextImpl ctx = new ELContextImpl(
+expressionFactory);
 
ctx.setFunctionMapper(getFunctionMapper(el));
 try {
 
jspAttrs[i].validateEL(this.pageInfo.getExpressionFactory(), ctx);
@@ -1377,7 +1378,8 @@ class Validator {
 result = new Node.JspAttribute(tai, qName, uri,
 localName, value, false, el, dynamic);
 
-ELContextImpl ctx = new ELContextImpl();
+ELContextImpl ctx =
+new ELContextImpl(expressionFactory);
 ctx.setFunctionMapper(getFunctionMapper(el));
 
 try {
@@ -1564,7 +1566,7 @@ class Validator {
 validateFunctions(el, n);
 
 // test it out
-ELContextImpl ctx = new ELContextImpl();
+ELContextImpl ctx = new ELContextImpl(expressionFactory);
 ctx.setFunctionMapper(this.getFunctionMapper(el));
 ExpressionFactory ef = this.pageInfo.getExpressionFactory();
 try {

Modified: tomcat/trunk/java/org/apache/jasper/el/ELContextImpl.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/el/ELContextImpl.java?rev=1504148&r1=1504147&r2=1504148&view=diff
==
--- tomcat/trunk/java/org/apache/jasper/el/ELContextImpl.java (original)
+++ tomcat/trunk/java/org/apache/jasper/el/ELContextImpl.java Wed Jul 17 
14:14:28 2013
@@ -25,10 +25,12 @@ import javax.el.BeanELResolver;
 import javax.el.CompositeELResolver;
 import javax.el.ELContext;
 import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
 import javax.el.FunctionMapper;
 import javax.el.ListELResolver;
 import javax.el.MapELResolver;
 import javax.el.ResourceBundleELResolver;
+import javax.el.StaticFieldELResolver;
 import javax.el.ValueExpression;
 import javax.el.VariableMapper;
 
@@ -95,8 +97,8 @@ public final class ELContextImpl extends
 
 private VariableMapper variableMapper;
 
-public ELContextImpl() {
-this(getDefaultResolver());
+public ELContextImpl(ExpressionFactory factory) {
+this(getDefaultResolver(factory));
 }
 
 public ELContextImpl(ELResolver resolver) {
@@ -129,11 +131,11 @@ public final class ELContextImpl extends
 this.variableMapper = variableMapper;
 }
 
-public static ELResolver getDefaultResolver() {
+public static ELResolver getDefaultResolver(ExpressionFactory factory) {
 if (Constants.IS_SECURITY_ENABLED) {
 CompositeELResolver defaultResolver = new CompositeELResolver();
-// TODO ExpressionFactory.getStreamELResolver()
-// TODO javax.el.StaticFieldResolver
+   

Re: svn commit: r1504148 - in /tomcat/trunk: java/org/apache/jasper/compiler/ java/org/apache/jasper/el/ java/org/apache/jasper/runtime/ test/javax/el/ test/org/apache/el/ test/org/apache/el/parser/ t

2013-07-17 Thread Nick Williams

On Jul 17, 2013, at 9:21 AM, Caldarale, Charles R wrote:

>> From: ma...@apache.org [mailto:ma...@apache.org] 
>> Subject: svn commit: r1504148
> 
>> URL: http://svn.apache.org/r1504148
>> Log:
>> Add the two new resolver types (stream and static) to Jasper in the correct 
>> order and modify JasperELResolver so the correct resolvers are skipped.
> 
> Did you really want to say "so the correct resolvers are skipped"?  Seems odd 
> to be skipping the proper ones, or perhaps I just don't understand how this 
> should work.
> 
> - Chuck

I read "so the correct resolvers are skipped" as "so the resolvers that should 
be skipped are skipped."

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



Re: svn commit: r1504148 - in /tomcat/trunk: java/org/apache/jasper/compiler/ java/org/apache/jasper/el/ java/org/apache/jasper/runtime/ test/javax/el/ test/org/apache/el/ test/org/apache/el/parser/ t

2013-07-17 Thread Mark Thomas
On 17/07/2013 15:21, Caldarale, Charles R wrote:
>> From: ma...@apache.org [mailto:ma...@apache.org] Subject: svn
>> commit: r1504148
> 
>> URL: http://svn.apache.org/r1504148 Log: Add the two new resolver
>> types (stream and static) to Jasper in the correct order and modify
>> JasperELResolver so the correct resolvers are skipped.
> 
> Did you really want to say "so the correct resolvers are skipped"?
> Seems odd to be skipping the proper ones, or perhaps I just don't
> understand how this should work.

Yes. I was trying to say "Make sure we skip the resolvers that are meant
to be skipped." since the new resolvers were inserted the indexes of the
entries on the array have changed.

Mark

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



RE: svn commit: r1504148 - in /tomcat/trunk: java/org/apache/jasper/compiler/ java/org/apache/jasper/el/ java/org/apache/jasper/runtime/ test/javax/el/ test/org/apache/el/ test/org/apache/el/parser/ t

2013-07-17 Thread Caldarale, Charles R
> From: Nick Williams [mailto:nicho...@nicholaswilliams.net] 
> Subject: Re: svn commit: r1504148

> I read "so the correct resolvers are skipped" as "so the resolvers 
> that should be skipped are skipped."

That interpretation makes much more sense.  I think the use of the word 
"correct" twice in the sentence to refer to completely different sets of 
resolvers creates the confusion.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


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



svn commit: r1504153 - in /tomcat/trunk/test: org/apache/el/TestELInJsp.java webapp/el-misc.jsp

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 14:32:00 2013
New Revision: 1504153

URL: http://svn.apache.org/r1504153
Log:
Add unit tests that check (very basically) that the new EL syntax works in a 
JSP. There are single tests for lambda expressions, streams and imports.
TODO: Figure out why the import test currently fails.

Modified:
tomcat/trunk/test/org/apache/el/TestELInJsp.java
tomcat/trunk/test/webapp/el-misc.jsp

Modified: tomcat/trunk/test/org/apache/el/TestELInJsp.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELInJsp.java?rev=1504153&r1=1504152&r2=1504153&view=diff
==
--- tomcat/trunk/test/org/apache/el/TestELInJsp.java (original)
+++ tomcat/trunk/test/org/apache/el/TestELInJsp.java Wed Jul 17 14:32:00 2013
@@ -388,6 +388,10 @@ public class TestELInJsp extends TomcatB
 assertEcho(result, "15-foo\\bar\\baz");
 assertEcho(result, "16-foo\\bar\\baz");
 assertEcho(result, "17-foo\\bar\\baz");
+assertEcho(result, "18-3");
+assertEcho(result, "19-4");
+// TODO Figure out why this doesn't work.
+// assertEcho(result, "20-" + Integer.MAX_VALUE);
 }
 
 @Test

Modified: tomcat/trunk/test/webapp/el-misc.jsp
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/el-misc.jsp?rev=1504153&r1=1504152&r2=1504153&view=diff
==
--- tomcat/trunk/test/webapp/el-misc.jsp (original)
+++ tomcat/trunk/test/webapp/el-misc.jsp Wed Jul 17 14:32:00 2013
@@ -36,5 +36,8 @@
 
 
 
+
+
+
   
 
\ No newline at end of file



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



RE: svn commit: r1504148 - in /tomcat/trunk: java/org/apache/jasper/compiler/ java/org/apache/jasper/el/ java/org/apache/jasper/runtime/ test/javax/el/ test/org/apache/el/ test/org/apache/el/parser/ t

2013-07-17 Thread Caldarale, Charles R
> From: ma...@apache.org [mailto:ma...@apache.org] 
> Subject: svn commit: r1504148

> URL: http://svn.apache.org/r1504148
> Log:
> Add the two new resolver types (stream and static) to Jasper in the correct 
> order and modify JasperELResolver so the correct resolvers are skipped.

Did you really want to say "so the correct resolvers are skipped"?  Seems odd 
to be skipping the proper ones, or perhaps I just don't understand how this 
should work.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


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



Re: Various shell-scripting idioms in bin/daemon.sh

2013-07-17 Thread Mladen Turk

On 07/17/2013 04:01 PM, sebb wrote:

May I suggest a short comment is added to the script to document why
-z and -n are not used?
Someone else reading the script in the future is going to wonder the same-z and 
-n


Some shells do not work well if variable is not set when using -z and -n.
In case FOO was not set at all they break, but work if FOO="" as expected.

Anyhow, IMHO 'if [ ".$FOO" != . ]' is more readable then 'if [ -n "$FOO" ]'
I always end wondering if I should use -z or -n :)

Regards
--
^TM

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



buildbot failure in ASF Buildbot on tomcat-trunk

2013-07-17 Thread buildbot
The Buildbot has detected a new failure on builder tomcat-trunk while building 
ASF Buildbot.
Full details are available at:
 http://ci.apache.org/builders/tomcat-trunk/builds/4707

Buildbot URL: http://ci.apache.org/

Buildslave for this Build: bb-vm_ubuntu

Build Reason: scheduler
Build Source Stamp: [branch tomcat/trunk] 1504148
Blamelist: markt

BUILD FAILED: failed compile_1

sincerely,
 -The Buildbot





Re: Various shell-scripting idioms in bin/daemon.sh

2013-07-17 Thread sebb
On 17 July 2013 15:50, Mladen Turk  wrote:
> On 07/17/2013 04:01 PM, sebb wrote:
>>
>> May I suggest a short comment is added to the script to document why
>> -z and -n are not used?
>> Someone else reading the script in the future is going to wonder the
>> same-z and -n
>
>
> Some shells do not work well if variable is not set when using -z and -n.
> In case FOO was not set at all they break, but work if FOO="" as expected.

OK, well that information could be added to the script.

> Anyhow, IMHO 'if [ ".$FOO" != . ]' is more readable then 'if [ -n "$FOO" ]'

Why not use:

if [ "$FOO" != "" ]

The . is not very obvious in some fonts, and it's more symmetrical to
quote both sides.

> I always end wondering if I should use -z or -n :)
>
>
> Regards
> --
> ^TM
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

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



Re: Various shell-scripting idioms in bin/daemon.sh

2013-07-17 Thread Mladen Turk

On 07/17/2013 06:05 PM, sebb wrote:


Why not use:

if [ "$FOO" != "" ]



Some shells do not allow that (comparing empty strings)


The . is not very obvious in some fonts, and it's more symmetrical to
quote both sides.



Some time its used [ "x$FOO" != x ]
The same way as '[ "x$FOO" = xyes ]', etc...

Quoting both sides is just wasting two bytes, but I saw that as well,
but it should be consistent trough the script.

Anyhow, so far I saw no complaints about that.
As far as its consistent, it's OK.


Regards
--
^TM

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



Re: svn commit: r1503857 - in /tomcat/trunk: java/javax/el/ java/org/apache/el/parser/ test/org/apache/el/parser/

2013-07-17 Thread Violeta Georgieva
2013/7/17 Mark Thomas wrote:
>
> On 17/07/2013 12:43, Mark Thomas wrote:
> > Violeta Georgieva  wrote:
> >
> >> Having the example from the test:
> >> (x->y->x-y)(2)(1)
> >>
> >> We may transform it like this:
> >> (()->y->2-y)()(1)
> >>
> >> So instead of returning right way when formalParameters.isEmpty()
> >>
> >> Shouldn't we have something like the one below in order to continue
> >> evaluation of the nested expression:
> >>
> >>
> >>
> >> --- org/apache/el/parser/AstLambdaExpression.java (revision 1504024)
> >> +++ org/apache/el/parser/AstLambdaExpression.java (working copy)
> >> @@ -54,9 +54,12 @@
> >>  LambdaExpression le = new LambdaExpression(formalParameters, ve);
> >> le.setELContext(ctx);
> >>
> >> +Object result = le;
> >> +int i = 2;
> >> if (formalParameters.isEmpty()) {
> >> // No formal parameters - invoke the expression
> >> -return le.invoke(ctx, (Object[]) null);
> >> +result = ((LambdaExpression) result).invoke(ctx,
> >> (Object[])
> >> null);
> >> +i++;
> >> }
> >>
> >>   // If there are method parameters, need to invoke the expression
> >> with
> >> @@ -64,8 +67,6 @@
> >> // should be that many nested expressions.
> >>  // If there are more nested expressions that parameters this will
> >> return
> >> // a LambdaExpression
> >> -Object result = le;
> >> -int i = 2;
> >> while (result instanceof LambdaExpression && i <
> >> jjtGetNumChildren()) {
> >> result = ((LambdaExpression) result).invoke(
> >> ((AstMethodParameters)
> >> children[i]).getParameters(ctx));
> >
> > I agree the current solution isn't right but I have some local test
cases that I'm fairly sure will still fail with the above patch. I'm
working on a fix and should have something to commit soon.
>
> Fix applied. What do you think?


Why it is expected that (()->y->()->x->x-y)()(1)()(2) should throw
ELException? (TestAstLambdaExpression.testNested04())
Isn't it a correct one?


svn commit: r1504232 - in /tomcat/trunk/test: org/apache/el/TestELInJsp.java webapp/el-misc.jsp

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 18:49:31 2013
New Revision: 1504232

URL: http://svn.apache.org/r1504232
Log:
The specification does not appear to allow the use of imports in a JSP page.

EL 3.0 section 1.5.1 states that the ELResolvers process identifiers before the 
ImportHandler

JSP 2.3 section JSP.2.9 defines a set of ELResolvers that will always produce a 
result hence the resolution of identifiers never progress to imports.

Modified:
tomcat/trunk/test/org/apache/el/TestELInJsp.java
tomcat/trunk/test/webapp/el-misc.jsp

Modified: tomcat/trunk/test/org/apache/el/TestELInJsp.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELInJsp.java?rev=1504232&r1=1504231&r2=1504232&view=diff
==
--- tomcat/trunk/test/org/apache/el/TestELInJsp.java (original)
+++ tomcat/trunk/test/org/apache/el/TestELInJsp.java Wed Jul 17 18:49:31 2013
@@ -370,6 +370,7 @@ public class TestELInJsp extends TomcatB
 ByteChunk res = getUrl("http://localhost:"; + getPort() +
 "/test/el-misc.jsp");
 String result = res.toString();
+
 assertEcho(result, "00-\\\"${'hello world'}");
 assertEcho(result, "01-\\\"\\${'hello world'}");
 assertEcho(result, "02-\\\"${'hello world'}");
@@ -390,8 +391,6 @@ public class TestELInJsp extends TomcatB
 assertEcho(result, "17-foo\\bar\\baz");
 assertEcho(result, "18-3");
 assertEcho(result, "19-4");
-// TODO Figure out why this doesn't work.
-// assertEcho(result, "20-" + Integer.MAX_VALUE);
 }
 
 @Test

Modified: tomcat/trunk/test/webapp/el-misc.jsp
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/el-misc.jsp?rev=1504232&r1=1504231&r2=1504232&view=diff
==
--- tomcat/trunk/test/webapp/el-misc.jsp (original)
+++ tomcat/trunk/test/webapp/el-misc.jsp Wed Jul 17 18:49:31 2013
@@ -38,6 +38,5 @@
 
 
 
-
   
 
\ No newline at end of file



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



svn commit: r1504234 - /tomcat/trunk/java/javax/el/LambdaExpression.java

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 18:58:17 2013
New Revision: 1504234

URL: http://svn.apache.org/r1504234
Log:
Use the correct message key

Modified:
tomcat/trunk/java/javax/el/LambdaExpression.java

Modified: tomcat/trunk/java/javax/el/LambdaExpression.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/LambdaExpression.java?rev=1504234&r1=1504233&r2=1504234&view=diff
==
--- tomcat/trunk/java/javax/el/LambdaExpression.java (original)
+++ tomcat/trunk/java/javax/el/LambdaExpression.java Wed Jul 17 18:58:17 2013
@@ -58,7 +58,7 @@ public class LambdaExpression {
 
 if (formalParamCount > argCount) {
 throw new ELException(Util.message(context,
-"error.lambda.args.tooFew",
+"lambdaExpression.tooFewArgs",
 Integer.valueOf(argCount),
 Integer.valueOf(formalParamCount)));
 }



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



Re: svn commit: r1503857 - in /tomcat/trunk: java/javax/el/ java/org/apache/el/parser/ test/org/apache/el/parser/

2013-07-17 Thread Mark Thomas
On 17/07/2013 19:17, Violeta Georgieva wrote:
> 2013/7/17 Mark Thomas wrote:
>>
>> On 17/07/2013 12:43, Mark Thomas wrote:
>>> Violeta Georgieva  wrote:
>>>
 Having the example from the test:
 (x->y->x-y)(2)(1)

 We may transform it like this:
 (()->y->2-y)()(1)

 So instead of returning right way when formalParameters.isEmpty()

 Shouldn't we have something like the one below in order to continue
 evaluation of the nested expression:



 --- org/apache/el/parser/AstLambdaExpression.java (revision 1504024)
 +++ org/apache/el/parser/AstLambdaExpression.java (working copy)
 @@ -54,9 +54,12 @@
  LambdaExpression le = new LambdaExpression(formalParameters, ve);
 le.setELContext(ctx);

 +Object result = le;
 +int i = 2;
 if (formalParameters.isEmpty()) {
 // No formal parameters - invoke the expression
 -return le.invoke(ctx, (Object[]) null);
 +result = ((LambdaExpression) result).invoke(ctx,
 (Object[])
 null);
 +i++;
 }

   // If there are method parameters, need to invoke the expression
 with
 @@ -64,8 +67,6 @@
 // should be that many nested expressions.
  // If there are more nested expressions that parameters this will
 return
 // a LambdaExpression
 -Object result = le;
 -int i = 2;
 while (result instanceof LambdaExpression && i <
 jjtGetNumChildren()) {
 result = ((LambdaExpression) result).invoke(
 ((AstMethodParameters)
 children[i]).getParameters(ctx));
>>>
>>> I agree the current solution isn't right but I have some local test
> cases that I'm fairly sure will still fail with the above patch. I'm
> working on a fix and should have something to commit soon.
>>
>> Fix applied. What do you think?
> 
> 
> Why it is expected that (()->y->()->x->x-y)()(1)()(2) should throw
> ELException? (TestAstLambdaExpression.testNested04())
> Isn't it a correct one?

That is a copy and paste error that is masking at least two bugs. I've
fixed one bug and am trying to track down why this expression won't
evaluate.

I need to look at your proposal above again.

Mark


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



Re: Various shell-scripting idioms in bin/daemon.sh

2013-07-17 Thread Christopher Schultz
Mladen,

On 7/17/13 1:07 PM, Mladen Turk wrote:
> On 07/17/2013 06:05 PM, sebb wrote:
>>
>> Why not use:
>>
>> if [ "$FOO" != "" ]
>>
> 
> Some shells do not allow that (comparing empty strings)

I don't know of a shell where "$FOO" would be unset and yet expand to
some non-zero-length string in a command. If that were the case, ".$FOO"
would then expand to the same non-zero-length string with a dot
pre-pended to it and the comparison wouldn't work, anyway.

In my patch, I used a "-z". I'll remove it if there is significant
concern that it is very non-standard.

Sebb, one reason to use the ".$FOO" trick can be found in O'Reilly's
/Unix Power Tools/. They point out that by testing for "$FOO" like this:

if [ "$FOO" = "somestring" ] ;

You run the risk of $FOO expanding to something like "-z" where it would
not result in a string comparison. I like the use of ".$FOO" (leading
dot) because it avoids this issue, but I think it's moot because of the
availability of the "-z" test.

I couldn't find a man page online for the "test" program (but of course
searching for "test man page" yields completely useless results).

-chris



signature.asc
Description: OpenPGP digital signature


svn commit: r1504256 - in /tomcat/trunk: java/org/apache/el/parser/AstLambdaExpression.java java/org/apache/el/parser/AstLambdaParameters.java java/org/apache/el/parser/AstMethodParameters.java test/o

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 20:07:48 2013
New Revision: 1504256

URL: http://svn.apache.org/r1504256
Log:
More nested lambda expression fixes.
Includes another test case and some simple debug code aimed at IDE debuggers.

Modified:
tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
tomcat/trunk/java/org/apache/el/parser/AstLambdaParameters.java
tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java
tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java

Modified: tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java?rev=1504256&r1=1504255&r2=1504256&view=diff
==
--- tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java Wed Jul 17 
20:07:48 2013
@@ -95,9 +95,24 @@ public class AstLambdaExpression extends
 result = ((LambdaExpression) result).invoke(
 ((AstMethodParameters) children[i]).getParameters(ctx));
 i++;
+while (i < jjtGetNumChildren() && children[i].jjtGetNumChildren() 
== 0) {
+i++;
+}
 }
 
 return result;
 }
+
+
+@Override
+public String toString() {
+// Purely for debug purposes. May not be complete or correct. Certainly
+// is not efficient. Be sure not to call this from 'real' code.
+StringBuilder result = new StringBuilder();
+for (Node n : children) {
+result.append(n.toString());
+}
+return result.toString();
+}
 }
 /* JavaCC - OriginalChecksum=071159eff10c8e15ec612c765ae4480a (do not edit 
this line) */

Modified: tomcat/trunk/java/org/apache/el/parser/AstLambdaParameters.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLambdaParameters.java?rev=1504256&r1=1504255&r2=1504256&view=diff
==
--- tomcat/trunk/java/org/apache/el/parser/AstLambdaParameters.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstLambdaParameters.java Wed Jul 17 
20:07:48 2013
@@ -17,10 +17,27 @@
 /* Generated By:JJTree: Do not edit this line. AstLambdaParameters.java 
Version 4.3 */
 package org.apache.el.parser;
 
-public
-class AstLambdaParameters extends SimpleNode {
-  public AstLambdaParameters(int id) {
-super(id);
-  }
+public class AstLambdaParameters extends SimpleNode {
+
+public AstLambdaParameters(int id) {
+super(id);
+}
+
+@Override
+public String toString() {
+// Purely for debug purposes. May not be complete or correct. Certainly
+// is not efficient. Be sure not to call this from 'real' code.
+StringBuilder result = new StringBuilder();
+result.append('(');
+if (children != null) {
+for (Node n : children) {
+result.append(n.toString());
+result.append(',');
+}
+}
+result.append(")->");
+return result.toString();
+}
+
 }
 /* JavaCC - OriginalChecksum=a8c1609257dac59e41c43d6ed91072c6 (do not edit 
this line) */

Modified: tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java?rev=1504256&r1=1504255&r2=1504256&view=diff
==
--- tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstMethodParameters.java Wed Jul 17 
20:07:48 2013
@@ -37,4 +37,20 @@ public final class AstMethodParameters e
 }
 return params.toArray(new Object[params.size()]);
 }
+
+@Override
+public String toString() {
+// Purely for debug purposes. May not be complete or correct. Certainly
+// is not efficient. Be sure not to call this from 'real' code.
+StringBuilder result = new StringBuilder();
+result.append('(');
+if (children != null) {
+for (Node n : children) {
+result.append(n.toString());
+result.append(',');
+}
+}
+result.append(')');
+return result.toString();
+}
 }

Modified: tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java?rev=1504256&r1=1504255&r2=1504256&view=diff
==
--- tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java 
(original)
+++ tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java Wed Jul 
17 20:07:48 2013
@@ -116,7 +116,7 @@ public cl

Re: svn commit: r1503857 - in /tomcat/trunk: java/javax/el/ java/org/apache/el/parser/ test/org/apache/el/parser/

2013-07-17 Thread Mark Thomas
On 17/07/2013 20:12, Mark Thomas wrote:
> On 17/07/2013 19:17, Violeta Georgieva wrote:

>> Why it is expected that (()->y->()->x->x-y)()(1)()(2) should throw
>> ELException? (TestAstLambdaExpression.testNested04())
>> Isn't it a correct one?
> 
> That is a copy and paste error that is masking at least two bugs. I've
> fixed one bug and am trying to track down why this expression won't
> evaluate.
> 
> I need to look at your proposal above again.

I added some debug code that helped track down what is going on.

I've fixed that issue but I'm fairly sure the logic could be clarified.
I'm planning on looking at that next.

Mark


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



svn commit: r1504281 - in /tomcat/trunk: java/org/apache/el/parser/AstLambdaExpression.java test/org/apache/el/parser/TestAstLambdaExpression.java

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 21:12:22 2013
New Revision: 1504281

URL: http://svn.apache.org/r1504281
Log:
More fun and games with nested lambda expressions.
Each invocation of a nested expression consumes a set of method parameters. 
Therefore nested lambda expressions that are invoked immediately (because they 
have no formal parameetrs) need to inform the outer expression of the 
invocation so the next invocation uses the correct method parameters.

Modified:
tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
tomcat/trunk/test/org/apache/el/parser/TestAstLambdaExpression.java

Modified: tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java?rev=1504281&r1=1504280&r2=1504281&view=diff
==
--- tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java Wed Jul 17 
21:12:22 2013
@@ -29,6 +29,8 @@ import org.apache.el.util.MessageFactory
 
 public class AstLambdaExpression extends SimpleNode {
 
+private int methodParameterIndex = 0;
+
 public AstLambdaExpression(int id) {
 super(id);
 }
@@ -73,37 +75,70 @@ public class AstLambdaExpression extends
 LambdaExpression le = new LambdaExpression(formalParameters, ve);
 le.setELContext(ctx);
 
-if (formalParameters.isEmpty() && jjtGetNumChildren() == 2) {
-// No formal parameters - invoke the expression
-return le.invoke(ctx, (Object[]) null);
-}
-
-// If there are method parameters, need to invoke the expression with
-// those parameters. If there are multiple sets of method parameters
-// there should be at least that many nested expressions.
-// If there are more nested expressions than sets of method parameters
-// this may return a LambdaExpression.
-// If there are more sets of method parameters than nested expressions
-// an ELException will have been thrown by the check at the start of
-// this method.
-// If the inner most expression(s) do not require parameters then a
-// value will be returned once the outermost expression that does
-// require a parameter has been evaluated.
-Object result = le;
-int i = 2;
-while (result instanceof LambdaExpression && i < jjtGetNumChildren()) {
-result = ((LambdaExpression) result).invoke(
-((AstMethodParameters) children[i]).getParameters(ctx));
-i++;
-while (i < jjtGetNumChildren() && children[i].jjtGetNumChildren() 
== 0) {
-i++;
+if (jjtGetNumChildren() == 2) {
+if (formalParameters.isEmpty()) {
+// No formal parameters or method parameters so invoke the
+// expression. If this is a nested expression inform the outer
+// expression that an invocation has occurred so the correct 
set
+// of method parameters are used for the next invocation.
+incMethodParameterIndex();
+return le.invoke(ctx, (Object[]) null);
+} else {
+// Has formal parameters but no method parameters so return the
+// expression for later evaluation
+return le;
 }
 }
 
+
+// Always have to invoke the outer-most expression
+methodParameterIndex = 2;
+Object result = le.invoke(((AstMethodParameters)
+children[methodParameterIndex]).getParameters(ctx));
+methodParameterIndex++;
+
+/*
+ * If there are multiple sets of method parameters there should be at
+ * least that many nested expressions.
+ *
+ * If there are more nested expressions than sets of method parameters
+ * this may return a LambdaExpression.
+ *
+ * If there are more sets of method parameters than nested expressions
+ * an ELException will have been thrown by the check at the start of
+ * this method.
+ *
+ * If the inner most expression(s) do not require parameters then a
+ * value will be returned once the outermost expression that does
+ * require a parameter has been evaluated.
+ *
+ * When invoking an expression if it has nested expressions that do not
+ * have formal parameters then they will be evaluated as as part of 
that
+ * invocation. In this case the method parameters associated with those
+ * nested expressions need to be skipped.
+ */
+while (result instanceof LambdaExpression &&
+methodParameterIndex < jjtGetNumChildren()) {
+result = ((LambdaExpression) result).invoke(((AstMethodParameters)
+ 

Re: svn commit: r1503857 - in /tomcat/trunk: java/javax/el/ java/org/apache/el/parser/ test/org/apache/el/parser/

2013-07-17 Thread Mark Thomas
On 17/07/2013 21:10, Mark Thomas wrote:
> On 17/07/2013 20:12, Mark Thomas wrote:
>> On 17/07/2013 19:17, Violeta Georgieva wrote:
> 
>>> Why it is expected that (()->y->()->x->x-y)()(1)()(2) should throw
>>> ELException? (TestAstLambdaExpression.testNested04())
>>> Isn't it a correct one?
>>
>> That is a copy and paste error that is masking at least two bugs. I've
>> fixed one bug and am trying to track down why this expression won't
>> evaluate.
>>
>> I need to look at your proposal above again.
> 
> I added some debug code that helped track down what is going on.
> 
> I've fixed that issue but I'm fairly sure the logic could be clarified.
> I'm planning on looking at that next.

As I was writing the comments for the simpler code, I realised there was
still a way to break it. I added to test case to prove that and then
fixed the evaluation again. At the moment I think lambda expressions are
working correctly but to be frank I'm just waiting for someone to find
the next tricky nested expression that breaks things again. Violeta,
over to you :)

Mark


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



svn commit: r1504286 - in /tomcat/trunk: java/org/apache/el/parser/AstIdentifier.java test/org/apache/el/parser/TestAstIdentifier.java

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 21:38:48 2013
New Revision: 1504286

URL: http://svn.apache.org/r1504286
Log:
Add some basic import tests and fix a couple of identified issues.

Added:
tomcat/trunk/test/org/apache/el/parser/TestAstIdentifier.java   (with props)
Modified:
tomcat/trunk/java/org/apache/el/parser/AstIdentifier.java

Modified: tomcat/trunk/java/org/apache/el/parser/AstIdentifier.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstIdentifier.java?rev=1504286&r1=1504285&r2=1504286&view=diff
==
--- tomcat/trunk/java/org/apache/el/parser/AstIdentifier.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstIdentifier.java Wed Jul 17 
21:38:48 2013
@@ -18,6 +18,7 @@
 
 package org.apache.el.parser;
 
+import javax.el.ELClass;
 import javax.el.ELException;
 import javax.el.MethodExpression;
 import javax.el.MethodInfo;
@@ -78,11 +79,27 @@ public final class AstIdentifier extends
 // EL Resolvers
 ctx.setPropertyResolved(false);
 Object result = ctx.getELResolver().getValue(ctx, null, this.image);
-if (!ctx.isPropertyResolved()) {
-throw new PropertyNotFoundException(MessageFactory.get(
-"error.resolver.unhandled.null", this.image));
+if (ctx.isPropertyResolved()) {
+return result;
 }
-return result;
+
+// Import
+result = ctx.getImportHandler().resolveClass(this.image);
+if (result != null) {
+return new ELClass((Class) result);
+}
+result = ctx.getImportHandler().resolveStatic(this.image);
+if (result != null) {
+try {
+return ((Class) result).getField(this.image).get(null);
+} catch (IllegalArgumentException | IllegalAccessException
+| NoSuchFieldException | SecurityException e) {
+throw new ELException(e);
+}
+}
+
+throw new PropertyNotFoundException(MessageFactory.get(
+"error.resolver.unhandled.null", this.image));
 }
 
 @Override

Added: tomcat/trunk/test/org/apache/el/parser/TestAstIdentifier.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/parser/TestAstIdentifier.java?rev=1504286&view=auto
==
--- tomcat/trunk/test/org/apache/el/parser/TestAstIdentifier.java (added)
+++ tomcat/trunk/test/org/apache/el/parser/TestAstIdentifier.java Wed Jul 17 
21:38:48 2013
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.el.parser;
+
+import javax.el.ELProcessor;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestAstIdentifier {
+
+@Test
+public void testImport01() {
+ELProcessor processor = new ELProcessor();
+Object result =
+processor.getValue("Integer.MAX_VALUE",
+Integer.class);
+Assert.assertEquals(Integer.valueOf(Integer.MAX_VALUE), result);
+}
+
+
+@Test
+public void testImport02() {
+ELProcessor processor = new ELProcessor();
+
processor.getELManager().getELContext().getImportHandler().importStatic(
+"java.lang.Integer.MAX_VALUE");
+Object result =
+processor.getValue("MAX_VALUE",
+Integer.class);
+Assert.assertEquals(Integer.valueOf(Integer.MAX_VALUE), result);
+}
+}

Propchange: tomcat/trunk/test/org/apache/el/parser/TestAstIdentifier.java
--
svn:eol-style = native



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



svn commit: r1504287 - /tomcat/trunk/test/org/apache/jasper/el/TestJasperELResolver.java

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 21:40:19 2013
New Revision: 1504287

URL: http://svn.apache.org/r1504287
Log:
Fix failing CI build. Another resolver was added.

Modified:
tomcat/trunk/test/org/apache/jasper/el/TestJasperELResolver.java

Modified: tomcat/trunk/test/org/apache/jasper/el/TestJasperELResolver.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/el/TestJasperELResolver.java?rev=1504287&r1=1504286&r2=1504287&view=diff
==
--- tomcat/trunk/test/org/apache/jasper/el/TestJasperELResolver.java (original)
+++ tomcat/trunk/test/org/apache/jasper/el/TestJasperELResolver.java Wed Jul 17 
21:40:19 2013
@@ -58,9 +58,9 @@ public class TestJasperELResolver {
 
 Assert.assertEquals(Integer.valueOf(count),
 getField("appResolversSize", resolver));
-Assert.assertEquals(8 + count,
+Assert.assertEquals(9 + count,
 ((ELResolver[])getField("resolvers", resolver)).length);
-Assert.assertEquals(Integer.valueOf(8 + count),
+Assert.assertEquals(Integer.valueOf(9 + count),
 getField("size", resolver));
 
 }



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



svn commit: r1504292 - /tomcat/trunk/RELEASE-NOTES

2013-07-17 Thread markt
Author: markt
Date: Wed Jul 17 21:46:15 2013
New Revision: 1504292

URL: http://svn.apache.org/r1504292
Log:
Prep for an 8.0.0-alpha release
Remove section on JNI. Not a frequent enough issue to mentioned in the release 
notes.
Clean up the contents list.

Modified:
tomcat/trunk/RELEASE-NOTES

Modified: tomcat/trunk/RELEASE-NOTES
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/RELEASE-NOTES?rev=1504292&r1=1504291&r2=1504292&view=diff
==
--- tomcat/trunk/RELEASE-NOTES (original)
+++ tomcat/trunk/RELEASE-NOTES Wed Jul 17 21:46:15 2013
@@ -28,11 +28,8 @@ CONTENTS:
 
 * Dependency Changes
 * API Stability
-* JNI Based Applications
 * Bundled APIs
 * Web application reloading and static fields in shared libraries
-* Tomcat on Linux
-* Enabling SSI and CGI Support
 * Security manager URLs
 * Symlinking static resources
 * Viewing the Tomcat Change Log
@@ -43,20 +40,16 @@ CONTENTS:
 ===
 Dependency Changes:
 ===
-Tomcat @VERSION_MAJOR_MINOR@ is designed to run on Java SE 6 and later.
-
-In addition, Tomcat @VERSION_MAJOR_MINOR@ uses the Eclipse JDT Java compiler 
for
-compiling JSP pages.  This means you no longer need to have the complete
-Java Development Kit (JDK) to run Tomcat, but a Java Runtime Environment
-(JRE) is sufficient.  The Eclipse JDT Java compiler is bundled with the
-binary Tomcat distributions.  Tomcat can also be configured to use the
-compiler from the JDK to compile JSPs, or any other Java compiler supported
-by Apache Ant.
+Tomcat @VERSION_MAJOR_MINOR@ is designed to run on Java SE 7 and later.
 
 
 ==
 API Stability:
 ==
+
+*** This is an alpha release. Currently no guarantees are made regarding API 
***
+*** stability.   
***
+
 The public interfaces for the following classes are fixed and will not be
 changed at all during the remaining lifetime of the @VERSION_MAJOR@.x series:
 - None
@@ -73,27 +66,6 @@ The remaining classes are considered par
 without notice between point releases.
 
 
-===
-JNI Based Applications:
-===
-Applications that require native libraries must ensure that the libraries have
-been loaded prior to use.  Typically, this is done with a call like:
-
-  static {
-System.loadLibrary("path-to-library-file");
-  }
-
-in some class.  However, the application must also ensure that the library is
-not loaded more than once.  If the above code were placed in a class inside
-the web application (i.e. under /WEB-INF/classes or /WEB-INF/lib), and the
-application were reloaded, the loadLibrary() call would be attempted a second
-time.
-
-To avoid this problem, place classes that load native libraries outside of the
-web application, and ensure that the loadLibrary() call is executed only once
-during the lifetime of a particular JVM.
-
-
 =
 Bundled APIs:
 =



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



Re: Various shell-scripting idioms in bin/daemon.sh

2013-07-17 Thread sebb
Regardless, please consider documenting the script to explain why it
does not use -n/-z if that is necessary to avoid bugs.

On 17 July 2013 20:26, Christopher Schultz  wrote:
> Mladen,
>
> On 7/17/13 1:07 PM, Mladen Turk wrote:
>> On 07/17/2013 06:05 PM, sebb wrote:
>>>
>>> Why not use:
>>>
>>> if [ "$FOO" != "" ]
>>>
>>
>> Some shells do not allow that (comparing empty strings)
>
> I don't know of a shell where "$FOO" would be unset and yet expand to
> some non-zero-length string in a command. If that were the case, ".$FOO"
> would then expand to the same non-zero-length string with a dot
> pre-pended to it and the comparison wouldn't work, anyway.
>
> In my patch, I used a "-z". I'll remove it if there is significant
> concern that it is very non-standard.
>
> Sebb, one reason to use the ".$FOO" trick can be found in O'Reilly's
> /Unix Power Tools/. They point out that by testing for "$FOO" like this:
>
> if [ "$FOO" = "somestring" ] ;
>
> You run the risk of $FOO expanding to something like "-z" where it would
> not result in a string comparison. I like the use of ".$FOO" (leading
> dot) because it avoids this issue, but I think it's moot because of the
> availability of the "-z" test.
>
> I couldn't find a man page online for the "test" program (but of course
> searching for "test man page" yields completely useless results).
>
> -chris
>

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



buildbot success in ASF Buildbot on tomcat-trunk

2013-07-17 Thread buildbot
The Buildbot has detected a restored build on builder tomcat-trunk while 
building ASF Buildbot.
Full details are available at:
 http://ci.apache.org/builders/tomcat-trunk/builds/4713

Buildbot URL: http://ci.apache.org/

Buildslave for this Build: bb-vm_ubuntu

Build Reason: scheduler
Build Source Stamp: [branch tomcat/trunk] 1504292
Blamelist: markt

Build succeeded!

sincerely,
 -The Buildbot





Re: Various shell-scripting idioms in bin/daemon.sh

2013-07-17 Thread Mladen Turk

On 07/17/2013 11:59 PM, sebb wrote:

Regardless, please consider documenting the script to explain why it
does not use -n/-z if that is necessary to avoid bugs.



It would be the same as documenting why one uses a+=1 instead a++ :)
I don't see where its written that one *must* use -n/-z at the first place.


Regards
--
^TM

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