Details
-
Type:
Patch submission
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: 2.2.1, 3.0.0-M1, 3.0.0-M2
-
Fix Version/s: Bug Backlog
-
Component/s: Core: Exception Handling
-
Labels:None
-
Environment:
Windows XP SP3 32bit
Sun JDK 1.6.0_18
JBoss AS 5.1.0
-
User impact:High
-
Similar Issues:None
Description
When an Exception is of type org.mule.api.lifecycle.LifecycleException, an exception message is sent twice to the outbound endpoint defined in the exception strategy.
Hereby the original source:
org.mule.AbstractExceptionListener
...
public void exceptionThrown(Exception e)
{
if (enableNotifications)
{
fireNotification(new ExceptionNotification(e));
}
logException(e);
handleTransaction(e);
Throwable t = getExceptionType(e, RoutingException.class);
if (t != null)
{
RoutingException re = (RoutingException) t;
handleRoutingException(re.getMuleMessage(), re.getEndpoint(), e);
return;
}
t = getExceptionType(e, MessagingException.class);
if (t != null)
{
MessagingException me = (MessagingException) t;
handleMessagingException(me.getMuleMessage(), e);
return;
}
t = getExceptionType(e, LifecycleException.class);
if (t != null)
{
LifecycleException le = (LifecycleException) t;
handleLifecycleException(le.getComponent(), e);
if (RequestContext.getEventContext() != null)
{
handleMessagingException(RequestContext.getEventContext().getMessage(), e);
}
else
{
logger.info("There is no current event available, routing Null message with the exception");
handleMessagingException(new DefaultMuleMessage(NullPayload.getInstance(), muleContext), e);
}
return;
}
handleStandardException(e);
}
...
That method must be replaced by the following source :
org.mule.AbstractExceptionListener
...
public void exceptionThrown(Exception e)
{
if (enableNotifications)
{
fireNotification(new ExceptionNotification(e));
}
logException(e);
handleTransaction(e);
Throwable t = getExceptionType(e, RoutingException.class);
if (t != null)
{
RoutingException re = (RoutingException) t;
handleRoutingException(re.getMuleMessage(), re.getEndpoint(), e);
return;
}
t = getExceptionType(e, MessagingException.class);
if (t != null)
{
MessagingException me = (MessagingException) t;
handleMessagingException(me.getMuleMessage(), e);
return;
}
t = getExceptionType(e, LifecycleException.class);
if (t != null)
{
LifecycleException le = (LifecycleException) t;
handleLifecycleException(le.getComponent(), e);
// if (RequestContext.getEventContext() != null)
// {
// handleMessagingException(RequestContext.getEventContext().getMessage(), e);
// }
// else
// {
// logger.info("There is no current event available, routing Null message with the exception");
// handleMessagingException(new DefaultMuleMessage(NullPayload.getInstance(), muleContext), e);
// }
return;
}
handleStandardException(e);
}
...
Please note the commented part.
As a matter of fact, this code is duplicated and already executed when abstract method handleLifecycleException(le.getComponent(), e) is called in the implementation class org.mule.DefaultExceptionStrategy.
org.mule.DefaultExceptionStrategy
...
public void handleLifecycleException(Object component, Throwable t)
{
// Do nothing special here. Overriding implmentations may want alter the
// behaviour
handleStandardException(t);
logger.error("The object that failed was: \n" + ObjectUtils.toString(component, "null"));
}
public void handleStandardException(Throwable t)
{
handleTransaction(t);
// Attempt to send the exception details to an endpoint if one is set
if (RequestContext.getEventContext() != null)
{
handleMessagingException(RequestContext.getEventContext().getMessage(), t);
}
else
{
logger.info("There is no current event available, routing Null message with the exception");
handleMessagingException(new DefaultMuleMessage(NullPayload.getInstance(), muleContext), t);
}
}
...