You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2009/03/18 17:50:08 UTC
svn commit: r755643 -
/servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
Author: gnodet
Date: Wed Mar 18 16:50:07 2009
New Revision: 755643
URL: http://svn.apache.org/viewvc?rev=755643&view=rev
Log:
SMXCOMP-469: Terminated exchanges are sometimes sent when an handling an exception, leading to errors
Modified:
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
Modified: servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
URL: http://svn.apache.org/viewvc/servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?rev=755643&r1=755642&r2=755643&view=diff
==============================================================================
--- servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java (original)
+++ servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java Wed Mar 18 16:50:07 2009
@@ -470,6 +470,7 @@
}
protected void processExchangeInTx(MessageExchange exchange, Transaction tx) {
+ ExchangeStatus oldStatus = exchange.getStatus();
try {
if (tx != null) {
transactionManager.resume(tx);
@@ -488,8 +489,10 @@
transactionManager.suspend();
}
}
- exchange.setError(t instanceof Exception ? (Exception) t : new Exception(t));
- channel.send(exchange);
+ if (oldStatus == ExchangeStatus.ACTIVE) {
+ exchange.setError(t instanceof Exception ? (Exception) t : new Exception(t));
+ channel.send(exchange);
+ }
} catch (Exception inner) {
logger.error("Error setting exchange status to ERROR", inner);
}
@@ -527,23 +530,26 @@
processExchangeInTx(exchange, tx);
return;
}
+ ExchangeStatus oldStatus = exchange.getStatus();
try {
processExchange(exchange);
- } catch (Exception e) {
- logger.error("Error processing exchange " + exchange, e);
+ } catch (Throwable t) {
+ logger.error("Error processing exchange " + exchange, t);
try {
// If we are transacted and this is a runtime exception
// try to mark transaction as rollback
- if (transactionManager != null &&
- transactionManager.getStatus() == Status.STATUS_ACTIVE &&
- exceptionShouldRollbackTx(e)) {
+ if (transactionManager != null
+ && transactionManager.getStatus() == Status.STATUS_ACTIVE
+ && exceptionShouldRollbackTx(t)) {
transactionManager.setRollbackOnly();
if (!container.handleTransactions()) {
transactionManager.suspend();
}
}
- exchange.setError(e);
- channel.send(exchange);
+ if (oldStatus == ExchangeStatus.ACTIVE) {
+ exchange.setError(t instanceof Exception ? (Exception) t : new Exception(t));
+ channel.send(exchange);
+ }
} catch (Exception inner) {
logger.error("Error setting exchange status to ERROR", inner);
}