mulesoft-consulting / json-logger

Drop-in replacement for default Mule Logger that outputs a JSON structure based on a predefined JSON schema
MIT License
68 stars 212 forks source link

json-logger causes stack trace of suppressed exceptions to be logged #17

Closed ryandcarter closed 4 years ago

ryandcarter commented 4 years ago

When using json-logger after a foreach that iterates an empty collection(which is valid). The log will output the following stacktrace:

Message               : next on empty iterator
Element               : basic-test/processors/1/processors/0 @ test:test.xml:82
Element DSL           : <logger message="#[payload]"></logger>
Error type            : MULE:UNKNOWN
FlowStack             : at basic-test(basic-test/processors/3 @ test:test.xml:86 (EkkND))
--------------------------------------------------------------------------------
Root Exception stack trace:
java.util.NoSuchElementException: next on empty iterator
    at scala.collection.Iterator$$anon$2.next(Iterator.scala:41)
    at scala.collection.Iterator$$anon$2.next(Iterator.scala:39)
    at scala.collection.immutable.StreamIterator.next(Stream.scala:1057)

No ERROR is actually thrown in the flow, the flow will continue to process normally. However, it seems the json-logger is dredging up some suppressed error or something and filling the logs and making it look like an error actually occurred. If you use the example below, 'NO ERROR ACTUALLY HAPPENED' will still execute and log, but it will also log the stack trace above.

NOTE: This only happens withjson-logger. Remove the json-logger or replace it with something else and there is no stack trace in the logs

 <flow name="basic-test">
    <scheduler doc:name="Scheduler">
      <scheduling-strategy>
        <fixed-frequency frequency="5" startDelay="5"  timeUnit="SECONDS" />
      </scheduling-strategy>
    </scheduler> 
    <set-payload value="#[output application/java --- []]" />

    <foreach>
      <logger message="#[payload]" />
    </foreach>  

    <json-logger:logger message="Ending invoking all callbacks" tracePoint="FLOW" config-ref="jlogConfig" doc:name="END"/>

    <logger message="NO ERROR ACTUALLY HAPPENED" />
  </flow>
ryandcarter commented 4 years ago

issue with runtime. :)