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 2008/09/02 18:07:23 UTC
svn commit: r691294 -
/servicemix/components/engines/servicemix-eip/trunk/src/main/java/org/apache/servicemix/eip/support/AbstractContentBasedRouter.java
Author: gnodet
Date: Tue Sep 2 09:07:22 2008
New Revision: 691294
URL: http://svn.apache.org/viewvc?rev=691294&view=rev
Log:
SM-1545: memory leak in content-based router
Modified:
servicemix/components/engines/servicemix-eip/trunk/src/main/java/org/apache/servicemix/eip/support/AbstractContentBasedRouter.java
Modified: servicemix/components/engines/servicemix-eip/trunk/src/main/java/org/apache/servicemix/eip/support/AbstractContentBasedRouter.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-eip/trunk/src/main/java/org/apache/servicemix/eip/support/AbstractContentBasedRouter.java?rev=691294&r1=691293&r2=691294&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-eip/trunk/src/main/java/org/apache/servicemix/eip/support/AbstractContentBasedRouter.java (original)
+++ servicemix/components/engines/servicemix-eip/trunk/src/main/java/org/apache/servicemix/eip/support/AbstractContentBasedRouter.java Tue Sep 2 09:07:22 2008
@@ -126,16 +126,22 @@
// Now copy input to new exchange
// We need to read the message once for finding routing target
// so ensure we have a re-readable source
- NormalizedMessage in = MessageUtil.copyIn(exchange);
- MessageUtil.transferToIn(in, tme);
- // Retrieve target
- ExchangeTarget target = getDestination(tme);
- target.configureTarget(tme, getContext());
- if (isForwardOperation() && tme.getOperation() == null) {
- tme.setOperation(exchange.getOperation());
+ try {
+ NormalizedMessage in = MessageUtil.copyIn(exchange);
+ MessageUtil.transferToIn(in, tme);
+ // Retrieve target
+ ExchangeTarget target = getDestination(tme);
+ target.configureTarget(tme, getContext());
+ if (isForwardOperation() && tme.getOperation() == null) {
+ tme.setOperation(exchange.getOperation());
+ }
+ // Send in to target
+ send(tme);
+ } catch (Exception e) {
+ // Clear the store on error
+ store.load(exchange.getExchangeId());
+ throw e;
}
- // Send in to target
- send(tme);
// Mimic the exchange on the other side and send to needed listener
} else {
String id = (String) exchange.getProperty(correlation);
@@ -155,13 +161,23 @@
// Reproduce faults to the other side and listeners
} else if (exchange.getFault() != null) {
store.store(exchange.getExchangeId(), exchange);
- MessageUtil.transferTo(exchange, org, "fault");
- send(org);
+ try {
+ MessageUtil.transferTo(exchange, org, "fault");
+ send(org);
+ } catch (Exception e) {
+ store.load(exchange.getExchangeId());
+ throw e;
+ }
// Reproduce answers to the other side
} else if (exchange.getMessage("out") != null) {
store.store(exchange.getExchangeId(), exchange);
- MessageUtil.transferTo(exchange, org, "out");
- send(org);
+ try {
+ MessageUtil.transferTo(exchange, org, "out");
+ send(org);
+ } catch (Exception e) {
+ store.load(exchange.getExchangeId());
+ throw e;
+ }
} else {
throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE
+ " but has no Out nor Fault message");