You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "squakez (via GitHub)" <gi...@apache.org> on 2023/12/05 15:09:58 UTC

Re: [I] OGNL Script not working anymore after upgrade to Camel-K 2.1.0 [camel-k]

squakez commented on issue #4936:
URL: https://github.com/apache/camel-k/issues/4936#issuecomment-1840985526

   I've had a look and it seems the behavior of the `getProperty()` changed from Camel 3 to Camel 4 though I did not manage to find any reference in the migration guides. At this stage I'm not sure if this could be even a bug. Here a simpler reproducer:
   ```
   - from:
       uri: "timer:yaml"
       parameters:
         period: "1000"
       steps:
         - setProperty:
             name: data
             simple: "2"
         - setBody:
                ognl: "@java.lang.String@valueOf('1')"
         - setBody:
               ognl: request.body.replaceAll('1', getProperty("data"))
         - log: "${body}"
     ```
   Running it with Camel K or Camel JBang against Camel version 3.20.1 works. (`camel run --camel-version=3.20.1 test.yaml`) When however we run it against version 4.0.0 fails with following error:
   ```
   2023-12-05 16:04:28.067  WARN 1135657 --- [ - timer://yaml] camel.component.timer.TimerConsumer : Error processing exchange. Exchange[544E3B0719CDF54-0000000000000001]. Caused by: [java.lang.NullPointerException - target is null for method getProperty]
   java.lang.NullPointerException: target is null for method getProperty
   	at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1620) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.ASTMethod.getValueBody(ASTMethod.java:72) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.SimpleNode.getValue(SimpleNode.java:206) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.ASTMethod.getValueBody(ASTMethod.java:69) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.SimpleNode.getValue(SimpleNode.java:206) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.ASTChain.getValueBody(ASTChain.java:117) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.SimpleNode.getValue(SimpleNode.java:206) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.Ognl.getValue(Ognl.java:408) ~[ognl-3.4.1.jar:3.4.1]
   	at ognl.Ognl.getValue(Ognl.java:383) ~[ognl-3.4.1.jar:3.4.1]
   	at org.apache.camel.language.ognl.OgnlExpression.evaluate(OgnlExpression.java:56) ~[camel-ognl-4.0.0.jar:4.0.0]
   	at org.apache.camel.processor.SetBodyProcessor.process(SetBodyProcessor.java:45) ~[camel-core-processor-4.0.0.jar:4.0.0]
   	at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:475) ~[camel-core-processor-4.0.0.jar:4.0.0]
   	at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeReactiveWork(DefaultReactiveExecutor.java:196) [camel-base-engine-4.0.0.jar:4.0.0]
   	at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:164) [camel-base-engine-4.0.0.jar:4.0.0]
   	at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59) [camel-base-engine-4.0.0.jar:4.0.0]
   	at org.apache.camel.processor.Pipeline.process(Pipeline.java:163) [camel-core-processor-4.0.0.jar:4.0.0]
   	at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:383) [camel-base-engine-4.0.0.jar:4.0.0]
   	at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:208) [camel-timer-4.0.0.jar:4.0.0]
   	at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76) [camel-timer-4.0.0.jar:4.0.0]
   	at java.util.TimerThread.mainLoop(Timer.java:566) [?:?]
   	at java.util.TimerThread.run(Timer.java:516) [?:?]
   ```
   @oscerd @davsclaus is this an expected change or is it possibly a bug? it seems that the `getProperty()` method tries to run against some (null) object instead of trying to get the data from the context.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org