Author: davsclaus
Date: Fri Nov 6 14:38:25 2009
New Revision: 833413
URL:
http://svn.apache.org/viewvc?rev=833413&view=revLog:
CAMEL-2146: Fixed type converter to honor Future ExecutionException even better by checking exception hierarchy.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingInflightRoutePolicyTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java?rev=833413&r1=833412&r2=833413&view=diff==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java Fri Nov 6 14:38:25 2009
@@ -24,6 +24,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
import org.apache.camel.CamelExecutionException;
import org.apache.camel.Exchange;
@@ -84,10 +85,14 @@
Object answer;
try {
answer = doConvertTo(type, exchange, value);
- } catch (CamelExecutionException e) {
- // rethrow exception exception as its not due to failed convertion
- throw e;
} catch (Exception e) {
+ // if its a ExecutionException then we have rethrow it as its not due to failed conversion
+ boolean execution = ObjectHelper.getException(ExecutionException.class, e) != null ||
+ ObjectHelper.getException(CamelExecutionException.class, e) != null;
+ if (execution) {
+ throw ObjectHelper.wrapCamelExecutionException(exchange, e);
+ }
+
// we cannot convert so return null
if (LOG.isDebugEnabled()) {
LOG.debug(NoTypeConversionAvailableException.createMessage(value, type)
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java?rev=833413&r1=833412&r2=833413&view=diff==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/FutureTypeConverter.java Fri Nov 6 14:38:25 2009
@@ -16,7 +16,6 @@
*/
package org.apache.camel.impl.converter;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.apache.camel.Converter;
@@ -66,16 +65,7 @@
LOG.trace("Getting future response");
}
- Object body;
- try {
- body = future.get();
- } catch (ExecutionException e) {
- if (e.getCause() instanceof Exception) {
- throw (Exception) e.getCause();
- } else {
- throw e;
- }
- }
+ Object body = future.get();
if (LOG.isTraceEnabled()) {
LOG.trace("Got future response");
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingInflightRoutePolicyTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingInflightRoutePolicyTest.java?rev=833413&r1=833412&r2=833413&view=diff==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingInflightRoutePolicyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingInflightRoutePolicyTest.java Fri Nov 6 14:38:25 2009
@@ -29,15 +29,12 @@
private int size = 100;
public void testThrottlingRoutePolicy() throws Exception {
- getMockEndpoint("mock:result").expectedMinimumMessageCount(size - 5);
+ getMockEndpoint("mock:result").expectedMessageCount(size);
for (int i = 0; i < size; i++) {
template.sendBody(url, "Message " + i);
}
- // now start the route
- context.startRoute("myRoute");
-
assertMockEndpointsSatisfied();
}
@@ -50,7 +47,7 @@
policy.setMaxInflightExchanges(10);
from(url)
- .routePolicy(policy).noAutoStartup().id("myRoute")
+ .routePolicy(policy)
.to("log:foo?groupSize=10").to("mock:result");
}
};