简体   繁体   中英

How to validate NullPayload as null within a Groovy script in Mule 3.7.3

Within a Groovy script I have the code:

if(payload != null && payload['result'] != null) {
    params ['result'] = payload['result']
}

The Payload received before coming to the Groovy component is org.mule.transport.NullPayload , so when I validate "payload" being null in the "if", it doesn't detect that is a null , which is expected since that class is intended for that purpose in Mule 3.7.3 , so then what is the best practice to validate an instance org.mule.transport.NullPayload as a null value?

只需使用

if(payload instanceof NullPayload)
message.getPayload() == null

Did the job for me on Mule 3.4. Guess it´s still valid in 3.7.

There is a bug ticket registered in the MuleSoft Jira related to this: https://www.mulesoft.org/jira/browse/MULE-6427

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM