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


I've been testing the OptionalELResolver added in: 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:

As a concrete example, looking at some Tomcat tests: 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(
at jakarta.el.Util.findMethod(
at jakarta.el.BeanELResolver.invoke(
at jakarta.el.CompositeELResolver.invoke(
at org.apache.el.parser.AstValue.getValue(
at org.apache.el.ValueExpressionImpl.getValue(


Paul Nicolucci

Back to the top