davsclaus commented on code in PR #26757:
URL: https://github.com/apache/camel/pull/26757#discussion_r4080278787


##########
components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java:
##########
@@ -535,6 +542,40 @@ exchange, describeBean(holder, beanName, exchange),
         return newResult;
     }
 
+    /** Says that the bean is not a Map with that key, as null is a value a 
key can hold. */
+    private static final Object NO_SUCH_KEY = new Object();
+
+    /**
+     * The value of the key on a Map bean when the method of that name does 
not exist, so that ${body.sku} reads the sku
+     * of a map the way ${body[sku]} does - what a map means in jq, JavaScript 
and Groovy too (CAMEL-24916).
+     * <p/>
+     * A method still wins: ${body.size} on a Map calls size() as before. A 
name that is not a key still fails, so a
+     * misspelled field is still reported.
+     *
+     * @return the value of the key, or {@link #NO_SUCH_KEY} when this is not 
that case

Review Comment:
   They are there — `BeanExpression.java` lines 555-559 on the branch tip 
(e9d45e6):
   
   ```
    * @param  holder     the bean the OGNL step is called on; null when there 
is none
    * @param  exchange   the exchange the bean is resolved against
    * @param  methodName the name that failed as a method call, and is tried as 
a key
    * @param  cause      the failure of that call, so that only a missing 
method is read as a key
    * @return            the value of the key, or {@link #NO_SUCH_KEY} when 
this is not that case
   ```
   
   This review looks to have run against the state before that push. To the two 
questions in it: `cause` is passed because the method must tell a missing 
method from a method that exists and threw - only `MethodNotFoundException` may 
be read as a key, anything else is a real error that must keep propagating. 
`holder` is nullable because the OGNL chain can reach a step with no bean 
resolved, and `getBean` is then not called at all.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to