Uploaded image for project: 'Mule'
  1. Mule
  2. MULE-4708

ObjectToJMSMessage does not close the InputStream source

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.2.5 (EE only), 3.0.0-M2
    • Labels:
      None
    • Environment:

      Windows XP SP2, Java(TM) SE Runtime Environment (build 1.6.0_17-b04)

    • Configuration:
      Hide

      <service name="FooService">
      <inbound>
      <file:inbound-endpoint path="input" pollingFrequency="1000"/>
      </inbound>
      <!-<log-component/>->
      <outbound>
      <pass-through-router>
      <jms:outbound-endpoint queue="ExampleQueue"/>
      </pass-through-router>
      </outbound>
      </service>

      Show
      <service name="FooService"> <inbound> < file:inbound-endpoint path="input" pollingFrequency="1000"/> </inbound> <!- <log-component/> -> <outbound> <pass-through-router> <jms:outbound-endpoint queue="ExampleQueue"/> </pass-through-router> </outbound> </service>

      Description

      org.mule.transport.jms.transformers.ObjectToJMSMessage class does not close the InputStream passed as an input argument. This can be a root of many unexpected behaviors, take the example service below. This example service processes the same file indefinitely, because standard ObjectToJMSMessage does not close the file input stream and org.mule.transport.file.ReceiverFileInputStream#close is the place where processed file is deleted/moved. If this method is not called, file:inbound-endpoint keeps opening and processing the same file over and over.

      If you uncomment the log-component, everything seems to work just fine. This is due to the org.mule.api.MuleEventContext#getMessageAsString invocation, which uses org.mule.transformer.simple.ObjectToString#doTransform behind the scenes. This transformer closes the InputStream properly causing the file to be removed. ObjectToJMSMessage then gets the String instead of InputStream.

      The bug is located in org.mule.transport.jms.JmsMessageUtils#toMessage method, patch for 2.2.1 is attached. BTW this class (and many other transformers) does a while loop for reading and buffering InputStream. This can be replaced by org.apache.commons.io.IOUtils#copy.

        Attachments

          Activity

            People

            • Assignee:
              dirk Dirk Olmes
              Reporter:
              tnurkiewicz Tomasz Nurkiewicz
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                PagerDuty

                Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.