java.lang.IllegalStateException: Payload was invalidated calling setPayload and the message is not collection anymore.

MuleSoft JIRA | Lee Cheng | 4 years ago
  1. 0

    Flow config is following: <flow name="testFlow1" doc:name="testFlow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" doc:name="HTTP"/> <custom-transformer class="test.ReqToContent" doc:name="Java"/> <all doc:name="All"> <component class="test.B" doc:name="B"/> <component class="test.C" doc:name="C"/> </all> <component class="test.CollctToString"/> </flow> There are two components in the one <All> router: public class B implements Callable { @Override public Object onCall(MuleEventContext eventContext) throws Exception { System.out.println("B"); return "B"; } public class C implements Callable { @Override public Object onCall(MuleEventContext eventContext) throws Exception { System.out.println("C"); return "C"; } } There is a component after the <All> router: public class CollctToString implements Callable { @Override public Object onCall(MuleEventContext eventContext) throws Exception { return "CollctToString"; } } Run the app, it will throw following exception after executing components B and C: java.lang.IllegalStateException: Payload was invalidated calling setPayload and the message is not collection anymore. at org.mule.DefaultMessageCollection.checkValidPayload(DefaultMessageCollection.java:107) at org.mule.DefaultMessageCollection.newThreadCopy(DefaultMessageCollection.java:312) at org.mule.DefaultMuleEvent.newThreadCopy(DefaultMuleEvent.java:779) at org.mule.RequestContext.newEvent(RequestContext.java:140) I debugged it and found the cause: DefaultMessageCollection.setPayload() has been called by DefaultMessageCollection.transformMessage(MuleEvent, Transformer). And DefaultMessageCollection.invalidatedPayload field value is true. The 2sec passing parameter of DefaultMessageCollection.transformMessage(MuleEvent, Transformer) method is a transformer which I do not custom, and it will transform message to a String result. I cannot understand what does the code " if (this.getPayload() == payload) " of DefaultMessageCollection.setPayload() mean, this.getPayload() is a collection and payload is a string by previous transformMessage() method. I think it should call addMessage(MuleMessage message) to add all objects returned from components in the <All> router. It's success when I insert a custom transformer for converting Collection between <All> router output data flow and component class CollctToString.

    MuleSoft JIRA | 4 years ago | Lee Cheng
    java.lang.IllegalStateException: Payload was invalidated calling setPayload and the message is not collection anymore.
  2. 0

    Flow config is following: <flow name="testFlow1" doc:name="testFlow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" doc:name="HTTP"/> <custom-transformer class="test.ReqToContent" doc:name="Java"/> <all doc:name="All"> <component class="test.B" doc:name="B"/> <component class="test.C" doc:name="C"/> </all> <component class="test.CollctToString"/> </flow> There are two components in the one <All> router: public class B implements Callable { @Override public Object onCall(MuleEventContext eventContext) throws Exception { System.out.println("B"); return "B"; } public class C implements Callable { @Override public Object onCall(MuleEventContext eventContext) throws Exception { System.out.println("C"); return "C"; } } There is a component after the <All> router: public class CollctToString implements Callable { @Override public Object onCall(MuleEventContext eventContext) throws Exception { return "CollctToString"; } } Run the app, it will throw following exception after executing components B and C: java.lang.IllegalStateException: Payload was invalidated calling setPayload and the message is not collection anymore. at org.mule.DefaultMessageCollection.checkValidPayload(DefaultMessageCollection.java:107) at org.mule.DefaultMessageCollection.newThreadCopy(DefaultMessageCollection.java:312) at org.mule.DefaultMuleEvent.newThreadCopy(DefaultMuleEvent.java:779) at org.mule.RequestContext.newEvent(RequestContext.java:140) I debugged it and found the cause: DefaultMessageCollection.setPayload() has been called by DefaultMessageCollection.transformMessage(MuleEvent, Transformer). And DefaultMessageCollection.invalidatedPayload field value is true. The 2sec passing parameter of DefaultMessageCollection.transformMessage(MuleEvent, Transformer) method is a transformer which I do not custom, and it will transform message to a String result. I cannot understand what does the code " if (this.getPayload() == payload) " of DefaultMessageCollection.setPayload() mean, this.getPayload() is a collection and payload is a string by previous transformMessage() method. I think it should call addMessage(MuleMessage message) to add all objects returned from components in the <All> router. It's success when I insert a custom transformer for converting Collection between <All> router output data flow and component class CollctToString.

    MuleSoft JIRA | 4 years ago | Lee Cheng
    java.lang.IllegalStateException: Payload was invalidated calling setPayload and the message is not collection anymore.
  3. 0

    How to get the required data when the payload after the all component is of CopyOnWriteArrayList<Object> type?

    Stack Overflow | 2 years ago
    java.lang.IllegalStateException: Payload was invalidated calling setPayload and the message is not collection anymore.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Mule returning a MessageCollection from component

    Stack Overflow | 3 years ago | Tad
    java.lang.IllegalStateException: Payload was invalidated calling setPayload and the message is not collection anymore.
  6. 0

    Mule returning a MessageCollection from component

    Stack Overflow | 3 years ago | Tad
    java.lang.IllegalStateException: Payload was invalidated calling setPayload and the message is not collection anymore.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Payload was invalidated calling setPayload and the message is not collection anymore.

      at org.mule.DefaultMessageCollection.checkValidPayload()
    2. Mule Core
      RequestContext.newEvent
      1. org.mule.DefaultMessageCollection.checkValidPayload(DefaultMessageCollection.java:107)
      2. org.mule.DefaultMessageCollection.newThreadCopy(DefaultMessageCollection.java:312)
      3. org.mule.DefaultMuleEvent.newThreadCopy(DefaultMuleEvent.java:779)
      4. org.mule.RequestContext.newEvent(RequestContext.java:140)
      4 frames