This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-13755 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2a5a161d22de831379bcbf0c2217e4f2754aeb57 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Jul 19 09:52:27 2019 +0200 CAMEL-13755: camel3 - Remove fault from camel-core/message and let it be component specific for camel-cxf and camel-spring-ws as its only used by SOAP-WS --- .../spring/processor/SpringFaultRouteTest.java | 31 -------- .../processor/SpringHandleFaultPerRouteTest.java | 29 ------- .../apache/camel/spring/processor/faultRoute.xml | 37 --------- .../camel/spring/processor/handlefaultperroute.xml | 46 ----------- .../src/main/java/org/apache/camel/Exchange.java | 2 - .../src/main/java/org/apache/camel/Message.java | 2 + .../org/apache/camel/RuntimeConfiguration.java | 14 ---- .../camel/impl/engine/AbstractCamelContext.java | 25 ------ .../camel/impl/engine/DefaultRouteContext.java | 13 ---- .../apache/camel/processor/FinallyProcessor.java | 26 +------ .../camel/processor/OnCompletionProcessor.java | 12 --- .../camel/processor/interceptor/HandleFault.java | 59 -------------- .../core/xml/AbstractCamelContextFactoryBean.java | 11 --- .../apache/camel/model/ProcessorDefinition.java | 12 --- .../org/apache/camel/model/RouteDefinition.java | 36 --------- .../org/apache/camel/reifier/ProcessorReifier.java | 11 +-- .../org/apache/camel/reifier/RouteReifier.java | 16 ---- .../apache/camel/reifier/SetFaultBodyReifier.java | 1 + .../camel/builder/FluentProducerTemplateTest.java | 6 -- .../org/apache/camel/impl/DefaultExchangeTest.java | 18 ----- .../camel/impl/DefaultProducerTemplateTest.java | 8 -- .../apache/camel/issues/OnCompletionIssueTest.java | 6 +- .../processor/ExceptionHandlerStreamCacheTest.java | 20 +---- .../FailOverLoadBalancerSetFaultTest.java | 2 - .../FaultRetryRouteNewConfigurationTest.java | 43 ---------- .../camel/processor/FaultRetryRouteTest.java | 83 -------------------- .../org/apache/camel/processor/FaultRouteTest.java | 91 ---------------------- .../camel/processor/HandleFaultPerRouteTest.java | 88 --------------------- .../org/apache/camel/processor/PipelineTest.java | 17 ---- .../camel/processor/TrySetFaultFinallyTest.java | 54 ------------- .../apache/camel/processor/TrySetFaultTest.java | 70 ----------------- .../async/AsyncEndpointWithHandleFaultTest.java | 82 ------------------- .../camel/processor/enricher/FailureProcessor.java | 1 + .../intercept/InterceptSendToFaultTest.java | 47 ----------- .../camel/main/DefaultConfigurationConfigurer.java | 6 -- .../org/apache/camel/support/DefaultExchange.java | 2 - .../camel/support/DefaultExchangeHolder.java | 14 ---- .../org/apache/camel/support/MessageSupport.java | 1 - 38 files changed, 11 insertions(+), 1031 deletions(-) diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFaultRouteTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFaultRouteTest.java deleted file mode 100644 index 8151914..0000000 --- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFaultRouteTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.processor; - -import org.apache.camel.CamelContext; -import org.apache.camel.processor.FaultRouteTest; - -import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext; - -/** - * The spring context test for the FaultRoute - */ -public class SpringFaultRouteTest extends FaultRouteTest { - protected CamelContext createCamelContext() throws Exception { - return createSpringCamelContext(this, "org/apache/camel/spring/processor/faultRoute.xml"); - } -} diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringHandleFaultPerRouteTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringHandleFaultPerRouteTest.java deleted file mode 100644 index 7b417ac..0000000 --- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringHandleFaultPerRouteTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.processor; - -import org.apache.camel.CamelContext; -import org.apache.camel.processor.HandleFaultPerRouteTest; - -import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext; - -public class SpringHandleFaultPerRouteTest extends HandleFaultPerRouteTest { - - protected CamelContext createCamelContext() throws Exception { - return createSpringCamelContext(this, "org/apache/camel/spring/processor/handlefaultperroute.xml"); - } -} \ No newline at end of file diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/faultRoute.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/faultRoute.xml deleted file mode 100644 index afe9d1d..0000000 --- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/faultRoute.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd - "> - - <!-- START SNIPPET: example --> - <camelContext handleFault="true" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <to uri="mock:a"/> - <to uri="mock:b"/> - </route> - </camelContext> - <!-- END SNIPPET: example --> - -</beans> diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/handlefaultperroute.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/handlefaultperroute.xml deleted file mode 100644 index 503f075..0000000 --- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/handlefaultperroute.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd - "> - - <camelContext handleFault="true" xmlns="http://camel.apache.org/schema/spring"> - - <route handleFault="true"> - <from uri="direct:a"/> - <to uri="mock:a"/> - </route> - - <route handleFault="false"> - <from uri="direct:b"/> - <to uri="mock:b"/> - </route> - - <route> - <from uri="direct:c"/> - <to uri="mock:c"/> - </route> - - </camelContext> - -</beans> diff --git a/core/camel-api/src/main/java/org/apache/camel/Exchange.java b/core/camel-api/src/main/java/org/apache/camel/Exchange.java index a61748d..35b5551 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Exchange.java +++ b/core/camel-api/src/main/java/org/apache/camel/Exchange.java @@ -488,8 +488,6 @@ public interface Exchange { * * @return true if this exchange failed due to either an exception or fault * @see Exchange#getException() - * @see Message#setFault(boolean) - * @see Message#isFault() */ boolean isFailed(); diff --git a/core/camel-api/src/main/java/org/apache/camel/Message.java b/core/camel-api/src/main/java/org/apache/camel/Message.java index e3022c0a..078ec1d 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Message.java +++ b/core/camel-api/src/main/java/org/apache/camel/Message.java @@ -58,6 +58,7 @@ public interface Message { * * @return <tt>true</tt> if this is a fault message, <tt>false</tt> for regular messages. */ + @Deprecated boolean isFault(); /** @@ -65,6 +66,7 @@ public interface Message { * * @param fault the fault flag */ + @Deprecated void setFault(boolean fault); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeConfiguration.java index 413a733..2078dc5 100644 --- a/core/camel-api/src/main/java/org/apache/camel/RuntimeConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeConfiguration.java @@ -107,20 +107,6 @@ public interface RuntimeConfiguration { Boolean isLogExhaustedMessageBody(); /** - * Sets whether fault handling is enabled or not (default is disabled). - * - * @param handleFault whether to enable fault handling. - */ - void setHandleFault(Boolean handleFault); - - /** - * Returns whether fault handling enabled - * - * @return <tt>true</tt> if fault handling is enabled - */ - Boolean isHandleFault(); - - /** * Sets a delay value in millis that a message is delayed at every step it takes in the route path, * slowing the process down to better observe what is occurring * <p/> diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java index 89f3e6a..11cdfdd 100644 --- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java +++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java @@ -78,7 +78,6 @@ import org.apache.camel.TypeConverter; import org.apache.camel.VetoCamelContextStartException; import org.apache.camel.impl.transformer.TransformerKey; import org.apache.camel.impl.validator.ValidatorKey; -import org.apache.camel.processor.interceptor.HandleFault; import org.apache.camel.spi.AnnotationBasedProcessorFactory; import org.apache.camel.spi.AsyncProcessorAwaitManager; import org.apache.camel.spi.BeanProcessorFactory; @@ -198,7 +197,6 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext private Boolean logMask = Boolean.FALSE; private Boolean logExhaustedMessageBody = Boolean.FALSE; private Boolean streamCache = Boolean.FALSE; - private Boolean handleFault = Boolean.FALSE; private Boolean disableJMX = Boolean.FALSE; private Boolean loadTypeConverters = Boolean.TRUE; private Boolean typeConverterStatisticsEnabled = Boolean.FALSE; @@ -1886,13 +1884,6 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext public void addInterceptStrategy(InterceptStrategy interceptStrategy) { getInterceptStrategies().add(interceptStrategy); - - // for backwards compatible or if user add them here instead of the - // setXXX methods - - if (interceptStrategy instanceof HandleFault) { - setHandleFault(true); - } } public List<RoutePolicyFactory> getRoutePolicyFactories() { @@ -1963,14 +1954,6 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext this.logExhaustedMessageBody = logExhaustedMessageBody; } - public Boolean isHandleFault() { - return handleFault; - } - - public void setHandleFault(Boolean handleFault) { - this.handleFault = handleFault; - } - public Long getDelayer() { return delay; } @@ -2446,14 +2429,6 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext log.info("MDC logging is enabled on CamelContext: {}", getName()); } - if (isHandleFault()) { - // only add a new handle fault if not already configured - if (HandleFault.getHandleFault(this) == null) { - log.info("HandleFault is enabled on CamelContext: {}", getName()); - addInterceptStrategy(new HandleFault()); - } - } - if (getDelayer() != null && getDelayer() > 0) { log.info("Delayer is enabled with: {} ms. on CamelContext: {}", getDelayer(), getName()); } diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRouteContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRouteContext.java index ebbc5a4..b055e28 100644 --- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRouteContext.java +++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRouteContext.java @@ -335,19 +335,6 @@ public class DefaultRouteContext implements RouteContext { } } - public void setHandleFault(Boolean handleFault) { - this.handleFault = handleFault; - } - - public Boolean isHandleFault() { - if (handleFault != null) { - return handleFault; - } else { - // fallback to the option from camel context - return getCamelContext().isHandleFault(); - } - } - public void setDelayer(Long delay) { this.delay = delay; } diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/FinallyProcessor.java b/core/camel-base/src/main/java/org/apache/camel/processor/FinallyProcessor.java index 411f967..be7be43 100644 --- a/core/camel-base/src/main/java/org/apache/camel/processor/FinallyProcessor.java +++ b/core/camel-base/src/main/java/org/apache/camel/processor/FinallyProcessor.java @@ -37,17 +37,7 @@ public class FinallyProcessor extends DelegateAsyncProcessor implements Traceabl @Override public boolean process(final Exchange exchange, final AsyncCallback callback) { - // clear exception and fault so finally block can be executed - final boolean fault; - if (exchange.hasOut()) { - fault = exchange.getOut().isFault(); - exchange.getOut().setFault(false); - } else { - fault = exchange.getIn().isFault(); - exchange.getIn().setFault(false); - } - - final Exception exception = exchange.getException(); + Exception exception = exchange.getException(); exchange.setException(null); // but store the caught exception as a property if (exception != null) { @@ -60,7 +50,7 @@ public class FinallyProcessor extends DelegateAsyncProcessor implements Traceabl } // continue processing - return processor.process(exchange, new FinallyAsyncCallback(exchange, callback, exception, fault)); + return processor.process(exchange, new FinallyAsyncCallback(exchange, callback, exception)); } @Override @@ -85,13 +75,11 @@ public class FinallyProcessor extends DelegateAsyncProcessor implements Traceabl private final Exchange exchange; private final AsyncCallback callback; private final Exception exception; - private final boolean fault; - FinallyAsyncCallback(Exchange exchange, AsyncCallback callback, Exception exception, boolean fault) { + FinallyAsyncCallback(Exchange exchange, AsyncCallback callback, Exception exception) { this.exchange = exchange; this.callback = callback; this.exception = exception; - this.fault = fault; } @Override @@ -104,14 +92,6 @@ public class FinallyProcessor extends DelegateAsyncProcessor implements Traceabl exchange.setException(exception); exchange.setProperty(Exchange.EXCEPTION_CAUGHT, exception); } - // set fault flag back - if (fault) { - if (exchange.hasOut()) { - exchange.getOut().setFault(true); - } else { - exchange.getIn().setFault(true); - } - } if (!doneSync) { // signal callback to continue routing async diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java b/core/camel-base/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java index d4ea972..09e7e81 100644 --- a/core/camel-base/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java +++ b/core/camel-base/src/main/java/org/apache/camel/processor/OnCompletionProcessor.java @@ -261,12 +261,6 @@ public class OnCompletionProcessor extends AsyncProcessorSupport implements Trac // must remove exception otherwise onFailure routing will fail as well // the caused exception is stored as a property (Exchange.EXCEPTION_CAUGHT) on the exchange copy.setException(null); - // must clear fault otherwise onFailure routing will fail as well - if (copy.hasOut()) { - copy.getOut().setFault(false); - } else { - copy.getIn().setFault(false); - } if (executorService != null) { executorService.submit(new Callable<Exchange>() { @@ -284,12 +278,6 @@ public class OnCompletionProcessor extends AsyncProcessorSupport implements Trac doProcess(processor, copy); // restore exception after processing copy.setException(original); - // restore fault after processing - if (copy.hasOut()) { - copy.getOut().setFault(originalFault); - } else { - copy.getIn().setFault(originalFault); - } } } diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/interceptor/HandleFault.java b/core/camel-base/src/main/java/org/apache/camel/processor/interceptor/HandleFault.java deleted file mode 100644 index 5f3d3a6..0000000 --- a/core/camel-base/src/main/java/org/apache/camel/processor/interceptor/HandleFault.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor.interceptor; - -import java.util.List; - -import org.apache.camel.CamelContext; -import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.NamedNode; -import org.apache.camel.Processor; -import org.apache.camel.spi.InterceptStrategy; - -/** - * {@link org.apache.camel.spi.InterceptStrategy} implementation to handle faults as exceptions on a RouteContext - */ -public final class HandleFault implements InterceptStrategy { - - public Processor wrapProcessorInInterceptors(CamelContext context, - NamedNode definition, Processor target, Processor nextTarget) throws Exception { - - return new HandleFaultInterceptor(target); - } - - /** - * A helper method to return the HandleFault instance - * for a given {@link org.apache.camel.CamelContext} if one is enabled - * - * @param context the camel context the handlefault intercept strategy is connected to - * @return the stream cache or null if none can be found - */ - public static HandleFault getHandleFault(CamelContext context) { - List<InterceptStrategy> list = context.adapt(ExtendedCamelContext.class).getInterceptStrategies(); - for (InterceptStrategy interceptStrategy : list) { - if (interceptStrategy instanceof HandleFault) { - return (HandleFault)interceptStrategy; - } - } - return null; - } - - @Override - public String toString() { - return "HandleFault"; - } -} \ No newline at end of file diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java index 8f7c223..86bdcfe 100644 --- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java +++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java @@ -77,7 +77,6 @@ import org.apache.camel.model.rest.RestDefinition; import org.apache.camel.model.transformer.TransformersDefinition; import org.apache.camel.model.validator.ValidatorsDefinition; import org.apache.camel.processor.interceptor.BacklogTracer; -import org.apache.camel.processor.interceptor.HandleFault; import org.apache.camel.runtimecatalog.JSonSchemaResolver; import org.apache.camel.runtimecatalog.RuntimeCamelCatalog; import org.apache.camel.spi.AsyncProcessorAwaitManager; @@ -200,11 +199,6 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex LOG.info("Using custom BacklogTracer: {}", backlogTracer); getContext().addService(backlogTracer); } - HandleFault handleFault = getBeanForType(HandleFault.class); - if (handleFault != null) { - LOG.info("Using custom HandleFault: {}", handleFault); - getContext().adapt(ExtendedCamelContext.class).addInterceptStrategy(handleFault); - } InflightRepository inflightRepository = getBeanForType(InflightRepository.class); if (inflightRepository != null) { LOG.info("Using custom InflightRepository: {}", inflightRepository); @@ -751,8 +745,6 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex public abstract String getDelayer(); - public abstract String getHandleFault(); - public abstract String getAutoStartup(); public abstract String getUseMDCLogging(); @@ -847,9 +839,6 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex if (getDelayer() != null) { context.setDelayer(CamelContextHelper.parseLong(context, getDelayer())); } - if (getHandleFault() != null) { - context.setHandleFault(CamelContextHelper.parseBoolean(context, getHandleFault())); - } if (getErrorHandlerRef() != null) { context.adapt(ExtendedCamelContext.class).setErrorHandlerFactory(new ErrorHandlerBuilderRef(getErrorHandlerRef())); } diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java index 741a015..52d8ccc 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java @@ -2526,18 +2526,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> } /** - * Adds a processor which sets the body on the FAULT message - * - * @param expression the expression used to set the body - * @return the builder - */ - public Type setFaultBody(Expression expression) { - SetFaultBodyDefinition answer = new SetFaultBodyDefinition(expression); - addOutput(answer); - return asType(); - } - - /** * Adds a processor which sets the header on the IN message * * @param name the header name diff --git a/core/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java index 8b2d1a4..9c4927d 100644 --- a/core/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java +++ b/core/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java @@ -59,7 +59,6 @@ public class RouteDefinition extends ProcessorDefinition<RouteDefinition> implem private String trace; private String messageHistory; private String logMask; - private String handleFault; private String delayer; private String autoStartup; private Integer startupOrder; @@ -344,26 +343,6 @@ public class RouteDefinition extends ProcessorDefinition<RouteDefinition> implem } /** - * Disable handle fault for this route. - * - * @return the builder - */ - public RouteDefinition noHandleFault() { - setHandleFault("false"); - return this; - } - - /** - * Enable handle fault for this route. - * - * @return the builder - */ - public RouteDefinition handleFault() { - setHandleFault("true"); - return this; - } - - /** * Disable delayer for this route. * * @return the builder @@ -776,21 +755,6 @@ public class RouteDefinition extends ProcessorDefinition<RouteDefinition> implem } /** - * Whether handle fault is enabled on this route. - */ - public String getHandleFault() { - return handleFault; - } - - /** - * Whether handle fault is enabled on this route. - */ - @XmlAttribute - public void setHandleFault(String handleFault) { - this.handleFault = handleFault; - } - - /** * Whether to slow down processing messages by a given delay in msec. */ public String getDelayer() { diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java b/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java index 1ecb803..c8685ec 100644 --- a/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java +++ b/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java @@ -102,7 +102,6 @@ import org.apache.camel.model.language.ExpressionDefinition; import org.apache.camel.processor.InterceptEndpointProcessor; import org.apache.camel.processor.Pipeline; import org.apache.camel.processor.channel.DefaultChannel; -import org.apache.camel.processor.interceptor.HandleFault; import org.apache.camel.reifier.errorhandler.ErrorHandlerReifier; import org.apache.camel.spi.IdAware; import org.apache.camel.spi.InterceptStrategy; @@ -418,15 +417,7 @@ public abstract class ProcessorReifier<T extends ProcessorDefinition<?>> { * @param strategies list of strategies to add. */ protected void addInterceptStrategies(RouteContext routeContext, List<InterceptStrategy> interceptors, List<InterceptStrategy> strategies) { - for (InterceptStrategy strategy : strategies) { - if (!routeContext.isHandleFault() && strategy instanceof HandleFault) { - // handle fault is disabled so we should not add it - continue; - } - - // add strategy - interceptors.add(strategy); - } + interceptors.addAll(strategies); } /** diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/RouteReifier.java b/core/camel-core/src/main/java/org/apache/camel/reifier/RouteReifier.java index 1675c38..ec490e3 100644 --- a/core/camel-core/src/main/java/org/apache/camel/reifier/RouteReifier.java +++ b/core/camel-core/src/main/java/org/apache/camel/reifier/RouteReifier.java @@ -40,7 +40,6 @@ import org.apache.camel.model.PropertyDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.RoutesDefinition; import org.apache.camel.processor.ContractAdvice; -import org.apache.camel.processor.interceptor.HandleFault; import org.apache.camel.reifier.rest.RestBindingReifier; import org.apache.camel.spi.Contract; import org.apache.camel.spi.LifecycleStrategy; @@ -245,21 +244,6 @@ public class RouteReifier extends ProcessorReifier<RouteDefinition> { } } - // configure handle fault - if (definition.getHandleFault() != null) { - Boolean isHandleFault = CamelContextHelper.parseBoolean(camelContext, definition.getHandleFault()); - if (isHandleFault != null) { - routeContext.setHandleFault(isHandleFault); - if (isHandleFault) { - log.debug("HandleFault is enabled on route: {}", definition.getId()); - // only add a new handle fault if not already a global configured on camel context - if (HandleFault.getHandleFault(camelContext) == null) { - definition.addInterceptStrategy(new HandleFault()); - } - } - } - } - // configure delayer if (definition.getDelayer() != null) { Long delayer = CamelContextHelper.parseLong(camelContext, definition.getDelayer()); diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/SetFaultBodyReifier.java b/core/camel-core/src/main/java/org/apache/camel/reifier/SetFaultBodyReifier.java index a8cd337..c948c7e 100644 --- a/core/camel-core/src/main/java/org/apache/camel/reifier/SetFaultBodyReifier.java +++ b/core/camel-core/src/main/java/org/apache/camel/reifier/SetFaultBodyReifier.java @@ -22,6 +22,7 @@ import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SetFaultBodyDefinition; import org.apache.camel.spi.RouteContext; +@Deprecated public class SetFaultBodyReifier extends ExpressionReifier<SetFaultBodyDefinition> { SetFaultBodyReifier(ProcessorDefinition<?> definition) { diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java index 5a7beb9..2cb75ad 100644 --- a/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java @@ -436,12 +436,6 @@ public class FluentProducerTemplateTest extends ContextTestSupport { from("direct:out") .process(exchange -> exchange.getOut().setBody("Bye Bye World")) .to("mock:result"); - from("direct:fault") - .process(exchange -> { - exchange.getOut().setFault(true); - exchange.getOut().setBody("Faulty World"); - }) - .to("mock:result"); from("direct:exception") .process(exchange -> { diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeTest.java index fea396a..c8026d9 100644 --- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeTest.java @@ -247,24 +247,6 @@ public class DefaultExchangeTest extends ExchangeTestSupport { sourceIn.getClass(), destIn.getClass()); } - @Test - public void testFaultSafeCopy() { - testFaultCopy(); - } - - private void testFaultCopy() { - DefaultExchange sourceExchange = new DefaultExchange(context); - MyMessage source = new MyMessage(context); - source.setFault(true); - sourceExchange.setIn(source); - sourceExchange.setOut(source); - Exchange destExchange = sourceExchange.copy(); - assertEquals("Fault property was not copied to IN message", - sourceExchange.getIn().isFault(), destExchange.getIn().isFault()); - assertEquals("Fault property was not copied to OUT message", - sourceExchange.getOut().isFault(), destExchange.getOut().isFault()); - } - public static class MyMessage extends DefaultMessage { public MyMessage(CamelContext camelContext) { super(camelContext); diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java index 8b75050..6050156 100644 --- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java @@ -274,14 +274,6 @@ public class DefaultProducerTemplateTest extends ContextTestSupport { } }).to("mock:result"); - from("direct:fault").process(new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getOut().setFault(true); - exchange.getOut().setBody("Faulty World"); - } - }).to("mock:result"); - from("direct:exception").process(new Processor() { @Override public void process(Exchange exchange) throws Exception { diff --git a/core/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java b/core/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java index 36419d6..ec4facf 100644 --- a/core/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java @@ -34,11 +34,10 @@ public class OnCompletionIssueTest extends ContextTestSupport { complete.expectedBodiesReceivedInAnyOrder("finish", "stop", "ile", "markRollback"); MockEndpoint failed = getMockEndpoint("mock:failed"); - failed.expectedBodiesReceivedInAnyOrder("faulted", "npe", "rollback"); + failed.expectedBodiesReceivedInAnyOrder("npe", "rollback"); template.sendBody("direct:input", "finish"); template.sendBody("direct:input", "stop"); - template.sendBody("direct:input", "fault"); template.sendBody("direct:input", "ile"); template.sendBody("direct:input", "markRollback"); @@ -80,9 +79,6 @@ public class OnCompletionIssueTest extends ContextTestSupport { .when(simple("${body} == 'stop'")) .log("stopping") .stop() - .when(simple("${body} == 'fault'")) - .log("faulting") - .setFaultBody(constant("faulted")) .when(simple("${body} == 'ile'")) .log("excepting") .throwException(new IllegalArgumentException("Exception requested")) diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ExceptionHandlerStreamCacheTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ExceptionHandlerStreamCacheTest.java index 1ec397e..8d28b04 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/ExceptionHandlerStreamCacheTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/ExceptionHandlerStreamCacheTest.java @@ -15,6 +15,7 @@ * limitations under the License. */ package org.apache.camel.processor; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -41,11 +42,6 @@ public class ExceptionHandlerStreamCacheTest extends ContextTestSupport { private MockEndpoint exceptionEndpoint; @Test - public void testSendFault() throws Exception { - doTestInputStreamPayload("fault"); - } - - @Test public void testSendError() throws Exception { doTestInputStreamPayload("error"); } @@ -64,11 +60,6 @@ public class ExceptionHandlerStreamCacheTest extends ContextTestSupport { } @Test - public void testSendFaultXml() throws Exception { - doTestXmlPayload("<fault/>"); - } - - @Test public void testSendErrorXml() throws Exception { doTestXmlPayload("<error/>"); } @@ -99,8 +90,7 @@ public class ExceptionHandlerStreamCacheTest extends ContextTestSupport { return new RouteBuilder() { public void configure() { - // enable support for handling faults and stream caching - context.setHandleFault(true); + // enable support for stream caching context.setStreamCaching(true); onException(Exception.class).handled(true).to("mock:exception"); @@ -109,12 +99,6 @@ public class ExceptionHandlerStreamCacheTest extends ContextTestSupport { public void process(Exchange exchange) throws Exception { String message = exchange.getIn().getBody(String.class); - if (message.contains("fault")) { - exchange.getOut().copyFrom(exchange.getIn()); - exchange.getOut().setBody(new ByteArrayInputStream(message.getBytes())); - exchange.getOut().setFault(true); - } - if (message.contains("error")) { throw new RuntimeException(message); } diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/FailOverLoadBalancerSetFaultTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/FailOverLoadBalancerSetFaultTest.java index 82241bf..621d2fd 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/FailOverLoadBalancerSetFaultTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/FailOverLoadBalancerSetFaultTest.java @@ -56,8 +56,6 @@ public class FailOverLoadBalancerSetFaultTest extends ContextTestSupport { public void process(Exchange exchange) throws Exception { // mutate the message exchange.getOut().setBody("Hi Camel"); - // and then set fault directly on OUT for example as camel-cxf would do - exchange.getOut().setFault(true); exchange.setException(new IOException("Forced exception for test")); } }); diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/FaultRetryRouteNewConfigurationTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/FaultRetryRouteNewConfigurationTest.java deleted file mode 100644 index 3faddd9..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/FaultRetryRouteNewConfigurationTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor; - -import org.apache.camel.LoggingLevel; -import org.apache.camel.builder.RouteBuilder; - -public class FaultRetryRouteNewConfigurationTest extends FaultRetryRouteTest { - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() { - getContext().setHandleFault(true); - - errorHandler( - deadLetterChannel("mock:error") - .maximumRedeliveries(4) - .loggingLevel(LoggingLevel.DEBUG)); - - from("direct:start") - .to("mock:a") - .process(successOnRetryProcessor) - .to("mock:b"); - } - }; - } -} \ No newline at end of file diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/FaultRetryRouteTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/FaultRetryRouteTest.java deleted file mode 100644 index f99c8d6..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/FaultRetryRouteTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor; -import org.apache.camel.CamelException; -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; -import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.LoggingLevel; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.processor.interceptor.HandleFault; -import org.junit.Before; -import org.junit.Test; - -public class FaultRetryRouteTest extends ContextTestSupport { - protected MockEndpoint a; - protected MockEndpoint b; - protected MockEndpoint error; - - protected final Processor successOnRetryProcessor = new Processor() { - int count; - public void process(Exchange exchange) throws CamelException { - if (count++ == 0) { - exchange.getOut().setFault(true); - exchange.getOut().setBody(new CamelException("Failed the first time")); - } - } - }; - - @Test - public void testSuccessfulRetry() throws Exception { - a.expectedBodiesReceived("in"); - b.expectedBodiesReceived("in"); - error.expectedMessageCount(0); - - template.sendBody("direct:start", "in"); - - MockEndpoint.assertIsSatisfied(a, b, error); - } - - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - a = resolveMandatoryEndpoint("mock:a", MockEndpoint.class); - b = resolveMandatoryEndpoint("mock:b", MockEndpoint.class); - error = resolveMandatoryEndpoint("mock:error", MockEndpoint.class); - } - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() { - getContext().adapt(ExtendedCamelContext.class).addInterceptStrategy(new HandleFault()); - - errorHandler( - deadLetterChannel("mock:error") - .maximumRedeliveries(4) - .loggingLevel(LoggingLevel.DEBUG)); - - from("direct:start") - .to("mock:a") - .process(successOnRetryProcessor) - .to("mock:b"); - } - }; - } -} diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/FaultRouteTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/FaultRouteTest.java deleted file mode 100644 index d96d0a7..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/FaultRouteTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor; -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; -import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.processor.interceptor.HandleFault; -import org.junit.Before; -import org.junit.Test; - -public class FaultRouteTest extends ContextTestSupport { - protected MockEndpoint a; - protected MockEndpoint b; - protected MockEndpoint c; - protected MockEndpoint err; - - @Test - public void testWithOut() throws Exception { - a.whenExchangeReceived(1, new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setBody("out"); - } - }); - a.expectedMessageCount(1); - b.expectedBodiesReceived("out"); - - template.sendBody("direct:start", "in"); - - assertMockEndpointsSatisfied(); - } - - @Test - public void testWithFault() throws Exception { - a.whenExchangeReceived(1, new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setFault(true); - exchange.getOut().setBody("fault"); - } - }); - a.expectedMessageCount(1); - b.expectedMessageCount(0); - - Exchange response = template.request("direct:start", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setBody("in"); - } - }); - assertMockEndpointsSatisfied(); - - assertFalse("Fault should be removed", response.hasOut()); - assertNotNull("Should have exception", response.getException()); - assertEquals("fault", response.getException().getMessage()); - } - - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - a = resolveMandatoryEndpoint("mock:a", MockEndpoint.class); - b = resolveMandatoryEndpoint("mock:b", MockEndpoint.class); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() { - getContext().adapt(ExtendedCamelContext.class).addInterceptStrategy(new HandleFault()); - - from("direct:start").to("mock:a").to("mock:b"); - } - }; - } -} diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/HandleFaultPerRouteTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/HandleFaultPerRouteTest.java deleted file mode 100644 index c74a07b..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/HandleFaultPerRouteTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -public class HandleFaultPerRouteTest extends ContextTestSupport { - - @Test - public void testHandleFaultPerRoute() throws Exception { - MockEndpoint a = getMockEndpoint("mock:a"); - a.expectedMessageCount(1); - - MockEndpoint b = getMockEndpoint("mock:b"); - b.expectedMessageCount(1); - - MockEndpoint c = getMockEndpoint("mock:c"); - c.expectedMessageCount(1); - - Exchange outA = template.send("direct:a", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setFault(true); - exchange.getOut().setBody(new IllegalArgumentException("A")); - } - }); - assertTrue("Should be failed", outA.isFailed()); - assertIsInstanceOf(IllegalArgumentException.class, outA.getException()); - assertEquals("A", outA.getException().getMessage()); - - Exchange outB = template.send("direct:b", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setFault(true); - exchange.getOut().setBody(new IllegalArgumentException("B")); - } - }); - - assertTrue("Should be failed", outB.isFailed()); - assertNull("Should not handle fault", outB.getException()); - assertTrue(outB.getOut() != null && outB.getOut().isFault()); - assertIsInstanceOf(IllegalArgumentException.class, outB.getOut().getBody()); - - Exchange outC = template.send("direct:c", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setFault(true); - exchange.getOut().setBody(new IllegalArgumentException("C")); - } - }); - - assertTrue("Should be failed", outC.isFailed()); - assertIsInstanceOf(IllegalArgumentException.class, outC.getException()); - assertEquals("C", outC.getException().getMessage()); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - context.setHandleFault(true); - - from("direct:a").to("mock:a"); - - from("direct:b").noHandleFault().to("mock:b"); - - from("direct:c").handleFault().to("mock:c"); - } - }; - } -} \ No newline at end of file diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java index 9a51ab4..16454bf 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java @@ -43,21 +43,6 @@ public class PipelineTest extends ContextTestSupport { } } - /** - * Simple processor the copies the in to the fault and increments a counter. - */ - private static final class InToFault implements Processor { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setFault(true); - exchange.getOut().setBody(exchange.getIn().getBody()); - Integer counter = exchange.getIn().getHeader("copy-counter", Integer.class); - if (counter == null) { - counter = 0; - } - exchange.getOut().setHeader("copy-counter", counter + 1); - } - } - protected MockEndpoint resultEndpoint; @Test @@ -153,8 +138,6 @@ public class PipelineTest extends ContextTestSupport { // Create a route that uses the InToOut processor 3 times. the copy-counter header should be == 3 from("direct:b").process(new InToOut()).process(new InToOut()).process(new InToOut()); - // Create a route that uses the InToFault processor.. the last InToOut will not be called since the Fault occurs before. - from("direct:c").process(new InToOut()).process(new InToFault()).process(new InToOut()); } }; } diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultFinallyTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultFinallyTest.java deleted file mode 100644 index 487d695..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultFinallyTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.builder.RouteBuilder; -import org.junit.Test; - -public class TrySetFaultFinallyTest extends ContextTestSupport { - - @Test - public void testSetFaultFinally() throws Exception { - getMockEndpoint("mock:a").expectedMessageCount(1); - getMockEndpoint("mock:b").expectedMessageCount(1); - getMockEndpoint("mock:c").expectedMessageCount(1); - getMockEndpoint("mock:result").expectedMessageCount(0); - - template.requestBody("direct:start", "Hello World"); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start") - .doTry() - .to("mock:a") - .setFaultBody(constant("Failed at A")) - .doFinally() - .to("mock:b") - .to("mock:c") - .end() - .to("mock:result"); - } - }; - } -} diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultTest.java deleted file mode 100644 index f4873cd..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.builder.RouteBuilder; -import org.junit.Test; - -public class TrySetFaultTest extends ContextTestSupport { - - @Test - public void testSetFault() throws Exception { - // only mock:start gets the message as a fault body stops routing - getMockEndpoint("mock:start").expectedMessageCount(1); - getMockEndpoint("mock:a").expectedMessageCount(0); - getMockEndpoint("mock:catch-a").expectedMessageCount(0); - getMockEndpoint("mock:b").expectedMessageCount(0); - getMockEndpoint("mock:catch-b").expectedMessageCount(0); - - template.requestBody("direct:start", "Hello World"); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start") - .to("mock:start") - .to("direct:a") - .to("mock:a") - .to("direct:b") - .to("mock:b"); - - from("direct:a") - .doTry() - .setFaultBody(constant("Failed at A")) - .doCatch(Exception.class) - // fault will not throw an exception - .to("mock:catch-a") - .end(); - - from("direct:b") - .doTry() - .setFaultBody(constant("Failed at B")) - .doCatch(Exception.class) - // fault will not throw an exception - .to("mock:catch-b") - .end() - .to("log:b"); - } - }; - } -} diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithHandleFaultTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithHandleFaultTest.java deleted file mode 100644 index 2afc961..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointWithHandleFaultTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor.async; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.junit.Test; - -public class AsyncEndpointWithHandleFaultTest extends ContextTestSupport { - - private static String beforeThreadName; - private static String afterThreadName; - - @Test - public void testAsyncEndpoint() throws Exception { - getMockEndpoint("mock:before").expectedBodiesReceived("Hello Camel"); - getMockEndpoint("mock:after").expectedMessageCount(0); - getMockEndpoint("mock:result").expectedMessageCount(0); - - Exchange reply = template.request("direct:start", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setBody("Hello Camel"); - } - }); - assertNotNull(reply); - assertTrue(reply.isFailed()); - assertNotNull(reply.getException()); - assertEquals("Faulty Bye Camel", reply.getException().getMessage()); - - assertMockEndpointsSatisfied(); - - assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName)); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - context.addComponent("async", new MyAsyncComponent()); - - // enable handle fault to ensure it works using async API - from("direct:start").handleFault() - .to("mock:before") - .to("log:before") - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - beforeThreadName = Thread.currentThread().getName(); - } - }) - .to("async:bye:camel") - .to("log:after") - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - afterThreadName = Thread.currentThread().getName(); - exchange.getOut().setFault(true); - exchange.getOut().setBody("Faulty Bye Camel"); - } - }) - .to("mock:after") - .to("mock:result"); - } - }; - } - -} \ No newline at end of file diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/FailureProcessor.java b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/FailureProcessor.java index aaa5ed8..e263075 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/FailureProcessor.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/FailureProcessor.java @@ -19,6 +19,7 @@ package org.apache.camel.processor.enricher; import org.apache.camel.Exchange; import org.apache.camel.Processor; +@Deprecated public class FailureProcessor implements Processor { private boolean error; diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToFaultTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToFaultTest.java deleted file mode 100644 index 146ed3d..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSendToFaultTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.processor.intercept; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.builder.RouteBuilder; -import org.junit.Test; - -public class InterceptSendToFaultTest extends ContextTestSupport { - - @Test - public void testInterceptSendToFault() throws Exception { - getMockEndpoint("mock:foo").expectedMessageCount(0); - getMockEndpoint("mock:result").expectedMessageCount(0); - - String out = template.requestBody("direct:start", "Hello World", String.class); - assertEquals("Damn", out); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - interceptSendToEndpoint("mock:foo").setFaultBody(constant("Damn")); - - from("direct:start").to("mock:foo").transform(constant("Bye World")).to("mock:result"); - } - }; - } -} \ No newline at end of file diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java index e88497a..533aa2c 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java @@ -33,7 +33,6 @@ import org.apache.camel.health.HealthCheckRepository; import org.apache.camel.health.HealthCheckService; import org.apache.camel.model.Model; import org.apache.camel.processor.interceptor.BacklogTracer; -import org.apache.camel.processor.interceptor.HandleFault; import org.apache.camel.spi.AsyncProcessorAwaitManager; import org.apache.camel.spi.ClassResolver; import org.apache.camel.spi.Debugger; @@ -136,7 +135,6 @@ public final class DefaultConfigurationConfigurer { camelContext.setMessageHistory(config.isMessageHistory()); camelContext.setLogMask(config.isLogMask()); camelContext.setLogExhaustedMessageBody(config.isLogExhaustedMessageBody()); - camelContext.setHandleFault(config.isHandleFault()); camelContext.setAutoStartup(config.isAutoStartup()); camelContext.setAllowUseOriginalMessage(config.isAllowUseOriginalMessage()); camelContext.setUseBreadcrumb(config.isUseBreadcrumb()); @@ -178,10 +176,6 @@ public final class DefaultConfigurationConfigurer { if (bt != null) { ecc.setExtension(BacklogTracer.class, bt); } - HandleFault hf = getSingleBeanOfType(registry, HandleFault.class); - if (hf != null) { - ecc.addInterceptStrategy(hf); - } InflightRepository ir = getSingleBeanOfType(registry, InflightRepository.class); if (ir != null) { ecc.setInflightRepository(ir); diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java index 5d4a8d3..7824fdb 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java @@ -98,14 +98,12 @@ public final class DefaultExchange implements Exchange { exchange.setIn(getIn().copy()); exchange.getIn().setBody(getIn().getBody()); - exchange.getIn().setFault(getIn().isFault()); if (getIn().hasHeaders()) { exchange.getIn().setHeaders(safeCopyHeaders(getIn().getHeaders())); } if (hasOut()) { exchange.setOut(getOut().copy()); exchange.getOut().setBody(getOut().getBody()); - exchange.getOut().setFault(getOut().isFault()); if (getOut().hasHeaders()) { exchange.getOut().setHeaders(safeCopyHeaders(getOut().getHeaders())); } diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchangeHolder.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchangeHolder.java index 46fdde3..b3aaead 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchangeHolder.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchangeHolder.java @@ -70,8 +70,6 @@ public class DefaultExchangeHolder implements Serializable { private String exchangeId; private Object inBody; private Object outBody; - private Boolean inFaultFlag = Boolean.FALSE; - private Boolean outFaultFlag = Boolean.FALSE; private Map<String, Object> inHeaders; private Map<String, Object> outHeaders; private Map<String, Object> properties; @@ -110,10 +108,7 @@ public class DefaultExchangeHolder implements Serializable { payload.safeSetInHeaders(exchange, false); if (exchange.hasOut()) { payload.outBody = checkSerializableBody("out body", exchange, exchange.getOut().getBody()); - payload.outFaultFlag = exchange.getOut().isFault(); payload.safeSetOutHeaders(exchange, false); - } else { - payload.inFaultFlag = exchange.getIn().isFault(); } if (includeProperties) { payload.safeSetProperties(exchange, false); @@ -147,10 +142,7 @@ public class DefaultExchangeHolder implements Serializable { payload.safeSetInHeaders(exchange, allowSerializedHeaders); if (exchange.hasOut()) { payload.outBody = checkSerializableBody("out body", exchange, exchange.getOut().getBody()); - payload.outFaultFlag = exchange.getOut().isFault(); payload.safeSetOutHeaders(exchange, allowSerializedHeaders); - } else { - payload.inFaultFlag = exchange.getIn().isFault(); } if (includeProperties) { payload.safeSetProperties(exchange, allowSerializedHeaders); @@ -175,17 +167,11 @@ public class DefaultExchangeHolder implements Serializable { if (payload.inHeaders != null) { exchange.getIn().setHeaders(payload.inHeaders); } - if (payload.inFaultFlag != null) { - exchange.getIn().setFault(payload.inFaultFlag); - } if (payload.outBody != null) { exchange.getOut().setBody(payload.outBody); if (payload.outHeaders != null) { exchange.getOut().setHeaders(payload.outHeaders); } - if (payload.outFaultFlag != null) { - exchange.getOut().setFault(payload.outFaultFlag); - } } if (payload.properties != null) { for (String key : payload.properties.keySet()) { diff --git a/core/camel-support/src/main/java/org/apache/camel/support/MessageSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/MessageSupport.java index d20a96d..4edb4b3 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/MessageSupport.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/MessageSupport.java @@ -213,7 +213,6 @@ public abstract class MessageSupport implements Message, CamelContextAware, Data setMessageId(that.getMessageId()); setBody(newBody); - setFault(that.isFault()); // the headers may be the same instance if the end user has made some mistake // and set the OUT message with the same header instance of the IN message etc