Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[el-dev] Question about the new OptionalELResolver

Hi,

I've been testing the OptionalELResolver added in: https://github.com/jakartaee/_expression_-language/issues/176. The initially reported problem does look to be resolved. For example an _expression_ of the form: "domainObject.optionalProperty.requiredProperty" works. However, I noticed that an _expression_ trying to invoke a method on the class of optionalProperty does not work: "domainObject.optionalProperty.someMethod()".

Was this the intention of the OptionalELResolver or was it an oversight that we should address? From my testing any method invocation is performed on Optional, so something like:  "domainObject.optionalProperty.toString()" works because of:https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html#toString().

As a concrete example, looking at some Tomcat tests: https://github.com/apache/tomcat/blob/main/test/jakarta/el/TestOptionalELResolver.java#L89 if we added a log() method to TesterBeanB and tried the following _expression_: ${beanA.beanBOpt.log()} then the following exception is seen:

jakarta.el.MethodNotFoundException: Method not found: class java.util.Optional.log()
at jakarta.el.Util.findWrapper(Util.java:365)
at jakarta.el.Util.findMethod(Util.java:209)
at jakarta.el.BeanELResolver.invoke(BeanELResolver.java:136)
at jakarta.el.CompositeELResolver.invoke(CompositeELResolver.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:159)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190)

Thanks,

Paul Nicolucci

Back to the top