title: Mule: prevent groovy component to overwrite payload
body: <p>I just realized that when I define a variable in my groovy script component Mule (3.4) overwrites the message payload with this variable.</p>
  
  <pre><code>def variable = "bar";
  </code></pre>
  
  <p>After the flow reaches a Groovy Component with this code, the payload is changed to "bar".</p>
  
  <p>How can I prevent this behaviour?</p>
  
  <p>To place the Groovy Component inside an enricher seems to be a solution, but the enricher is kind of a "transport barrier" and I have to update manually every single flow variable and session variable I change in the Component. This is error prone.</p>
  
  <p>complete flow code:</p>
  
  <pre><code>&lt;flow name="test-groovyFlow" doc:name="test-groovyFlow"&gt;
      &lt;http:inbound-endpoint exchange-pattern="request-response" host="0.0.0.0" port="8081" doc:name="HTTP" path="test_groovy"/&gt;
      &lt;set-payload value="foo" doc:name="payload = foo"/&gt;
      &lt;scripting:component doc:name="do something"&gt;
          &lt;scripting:script engine="Groovy"&gt;&lt;![CDATA[
             def variable = "bar";
          ]]&gt;&lt;/scripting:script&gt;
      &lt;/scripting:component&gt;
      &lt;scripting:transformer doc:name="Create Response"&gt;
          &lt;scripting:script engine="Groovy"&gt;&lt;![CDATA[
            new java.lang.String(
                 "payload: " + message.payload + "\n"
            )
          ]]&gt;&lt;/scripting:script&gt;
      &lt;/scripting:transformer&gt;
  &lt;/flow&gt;
  </code></pre>