Mule MEL for NullPayload vs null

According to the following ticket: https://www.mulesoft.org/jira/browse/MULE-6427 For NullPayload I should be able to use:

 <when expression="#[payload == null]"> 

but it fails. Therefore, I should use instead:

 <when expression="#[payload is NullPayload]"> 

Am I doing something wrong? Or is this the correct way to check for null or NullPayload ?

+5
source share
5 answers

In theory, this should be fixed, but it is not. I am using CE 3.4.0, and the expression #[payload == null] does not work for NullPayload .

I found this link that shows how to properly check the NullPayload :

 #[payload is org.mule.transport.NullPayload] 

I really needed to know if the payload was not NullPayload , so my expression was:

 #[!(payload is org.mule.transport.NullPayload)] 

Works like a charm. :)

+8
source

In Mule 3.7 (Studio 5.2) for NullPayload , #[payload == null] now returns true . Interestingly, #[payload is NullPayload] returns false .

+3
source

Try it:

#[payload == empty]

+1
source

This works on version 3.5: #[payload is NullPayload]

+1
source

This seems to be still true in the latest version of Mule according to this code .

This will not work if you are in version <than 3.4

0
source

Source: https://habr.com/ru/post/1208424/


All Articles