JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Use Agile By Default
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Create Issue
  • Mule
  • MULE-4955

Refactor Exception Strategy invocation so we don't get exception strategies invoked twice

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.2.5 (EE only)
  • Fix Version/s: 2.2.6 (EE only), 3.0.0-RC3
  • Component/s: Core: Exception Handling
  • Labels:
    • 30ce_blck
  • User impact:
    High
  • Migration Impact:
    People need to know that exceptions will only be handled by the listener closer to where the exception happens.
  • Similar Issues:
    None

Description

There are several cases in which exceptions are being handled twice by exception listeners. I worked on MULE-4924 and MULE-4927, but the issue is more general. Issue EE-1968 shows this.

For example:
We have this when the exception occurs inside a transformer on the outbound endpoint and we are inside an xa transaction.

In that use case these two calls are in the stack when the exception is thrown:

  • WebSphereMQMessageDispatcher(AbstractMessageDispatcher).send(MuleEvent) line: 165
    • Exception gets handled and rethrown here at:
      • WebSphereMQMessageDispatcher(AbstractMessageDispatcher).send(MuleEvent) line: 200
  • TransactionTemplate.execute(TransactionCallback) line: 114
    • Exception gets handled and not rethrown here:
      • TransactionTemplate.execute(TransactionCallback) line: 138

The problem is that we cannot avoid the throwing of the exception inside the AbstractMessageDispatcher because we need that exception for the TransactionTemplate to know there was an exception (for example, to rollback a transaction).
And in the TransactionTemplate we have no way of telling it the exception was handled or not.

I think we need some marker on the Exceptions that would tell us when they have been handled.

The proposed solution:

The idea is to have some marker on the MuleException and MuleRuntimeException that would let us know if an exception was already handled or not. Probably by making both of them implement a new interface called something like MuleHandleStatusException that would have a isAlreadyHandled() and a setAlreadyHandled(boolean handled).

We would also have a MuleExceptionHandlingUtil with a method that could be called boolean handledExceptionIfNeeded(ExceptionListener listener, Exception e) that would take care of detecting if somewhere in the causes of that exception there is a MuleHandleStatusException and check its status. It could return true if the exception is handled and false if it was already handled.

We can then change all the lines similar to this:
exceptionListener.exceptionThrown(e);
to
MuleExceptionHandlingUtil.handledExceptionIfNeeded(exceptionListener, e);

Potential Problems:

Some decisions made:

  • What should we do if we mark an exception as handled and later someone else in the stack encapsulates it in another exception?
    • We will only handle it once. It won't be rehandled even if encapsulated
  • What do we do with exceptions that are neither MuleException nor MuleRuntimeException (ie, that don't implement MuleHandleStatusException)?
    • This case should be very rare (I've seen a lot of places where we catch Exception and we encapsulate it with some MuleException or another). As we don't have a way of know if it was already handled or not, we will handle it everytime.

Issue Links

relates to

Bug - A problem which impairs or prevents the functions of the product. MULE-4927 Exception strategy invoked both for connector *and* service exception strategies when exception on sync outbound endpoint

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Bug - A problem which impairs or prevents the functions of the product. MULE-4924 Exception strategy invoked twice on TransactionTemplate

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions
  • Commits
  • Source
  • Builds

People

  • Assignee:
    Edu Pereda
    Reporter:
    Edu Pereda
Vote (0)
Watch (0)

Dates

  • Created:
    12/Jul/10 01:42 PM
    Updated:
    01/Sep/10 11:26 AM
    Resolved:
    01/Sep/10 11:26 AM

Agile

  • View on Board
  • Atlassian JIRA (v5.0.7#734-sha1:8ad78a6)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for MuleForge. Try JIRA - bug tracking software for your team.