谁能解释为什么会发生以下行为?为什么在使用逻辑 AND 时操作数的顺序很重要?在 mule-ce 3.3.1 上运行。
输出如下:
true
true
false
true
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<flow name="testFlow1" doc:name="testFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="20005" path="test" doc:name="HTTP"/>
<message-properties-transformer overwrite="true" scope="session" doc:name="Message Properties">
<add-message-property key="productNumber" value="1" />
</message-properties-transformer>
<logger level="INFO" message="#[(sessionVars['productNumber'] == '1' || sessionVars['productNumber'] == '2') and (sessionVars['quantity'] == null)]" doc:name="Logger"/>
<!-- true -->
<logger level="INFO" message="#[(sessionVars['quantity'] == null) and (sessionVars['productNumber'] == '1' || sessionVars['productNumber'] == '2')]" doc:name="Logger"/>
<!-- true -->
<message-properties-transformer overwrite="true" scope="session" doc:name="Message Properties">
<add-message-property key="productNumber" value="3" />
</message-properties-transformer>
<logger level="INFO" message="#[(sessionVars['productNumber'] == '1' || sessionVars['productNumber'] == '2') and (sessionVars['quantity'] == null)]" doc:name="Logger"/>
<!-- false -->
<logger level="INFO" message="#[(sessionVars['quantity'] == null) and (sessionVars['productNumber'] == '1' || sessionVars['productNumber'] == '2')]" doc:name="Logger"/>
<!-- true? it should not be true! -->
</flow>
</mule>