Claus Ibsen created CAMEL-26566:
-----------------------------------

             Summary: camel-groovy - a script that returns a GString gives a 
String
                 Key: CAMEL-26566
                 URL: https://issues.apache.org/jira/browse/CAMEL-26566
             Project: Camel
          Issue Type: Bug
          Components: camel-groovy
            Reporter: Claus Ibsen
             Fix For: 4.24.0


A Groovy expression such as "not enough ${sku}" returns a GString 
(org.codehaus.groovy.runtime.GStringImpl), not a String. GroovyExpression 
converts the result to the type that is asked for, and setBody, setHeader, 
setVariable and transform ask for Object, so the GString stays as it is.

A GString is not equal to a String, and components that check for a String do 
not take it as text. camel-jms, for example, sends it as an ObjectMessage, 
which is off by default since Camel 4.14, so the exchange fails with "JMS 
ObjectMessage is disabled by default ...". With objectMessageEnabled=true it 
then fails with "JMS ObjectMessage deserialization blocked for class: 
org.codehaus.groovy.runtime.GStringImpl".

The Python and JavaScript languages already return a String for their text. A 
Groovy expression or script that returns a GString should give a String too.

Found by the local-model benchmark (example connect-service-jms-request-reply): 
all 6 runs that wrote a Groovy script in the stock service step hit it.

What users can notice: a body, header or variable that a Groovy expression sets 
is now a String where it was a GString, and a predicate that returns the 
GString "false" or "" no longer matches.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to