Hi,

I tried to test the different o.a.el.stream.Optional methods.

Again I used one of our tests and modify
it: (o.a.el.stream.TestCollectionOperations.testAverage03())


[].stream().average().orElseGet(()->64)


I received:

javax.el.ELException: Cannot convert 64 of type class java.lang.Long to
class javax.el.LambdaExpression
at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:482)
at
org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:48)
at javax.el.Util.buildParameters(Util.java:351)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:173)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:84)
at org.apache.el.parser.AstValue.getValue(AstValue.java:146)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:188)
at javax.el.ELProcessor.getValue(ELProcessor.java:45)


The problem is the following:

When in o.a.el.parser.AstValue.getValue(EvaluationContext)

                AstMethodParameters mps =
                    (AstMethodParameters) this.children[i+1]; -> This
returns ()->64
                // This is a method
                base = resolver.invoke(ctx, base, suffix, null,
                        mps.getParameters(ctx));                    -> when
getParameters is invoked the lambda expression is evaluated and 64 is
returned as a result


Then BeanElResolver tries to invoke
o.a.el.stream.Optional.orElseGet(LambdaExpression) with Long and not with
LambdaExpression.

Regards
Violeta

Reply via email to