This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit a51d28bd0bab5b80b23996d9060a562735cb5cdc Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Oct 23 13:17:00 2020 +0200 CAMEL-15732: Untangle reifier from builder. --- .../ErrorHandlerCamelContextRefNotFoundTest.java | 2 +- .../ErrorHandlerRouteContextRefNotFoundTest.java | 2 +- .../reifier/errorhandler/ErrorHandlerReifier.java | 23 ++++++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java index 1ebe021..7dde62e 100644 --- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java @@ -39,7 +39,7 @@ public class ErrorHandlerCamelContextRefNotFoundTest extends SpringTestSupport { FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e); NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause()); assertEquals( - "No bean could be found in the registry for: foo of type: org.apache.camel.builder.ErrorHandlerBuilder", + "No bean could be found in the registry for: foo of type: org.apache.camel.ErrorHandlerFactory", nsbe.getMessage()); } } diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java index 91f04fe..7548d1e 100644 --- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java @@ -39,7 +39,7 @@ public class ErrorHandlerRouteContextRefNotFoundTest extends SpringTestSupport { FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e); NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause()); assertEquals( - "No bean could be found in the registry for: bar of type: org.apache.camel.builder.ErrorHandlerBuilder", + "No bean could be found in the registry for: bar of type: org.apache.camel.ErrorHandlerFactory", nsbe.getMessage()); } } diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/errorhandler/ErrorHandlerReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/errorhandler/ErrorHandlerReifier.java index 614f52f..be10ddd 100644 --- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/errorhandler/ErrorHandlerReifier.java +++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/errorhandler/ErrorHandlerReifier.java @@ -82,14 +82,21 @@ public abstract class ErrorHandlerReifier<T extends ErrorHandlerFactory> extends public static ErrorHandlerReifier<? extends ErrorHandlerFactory> reifier(Route route, ErrorHandlerFactory definition) { BiFunction<Route, ErrorHandlerFactory, ErrorHandlerReifier<? extends ErrorHandlerFactory>> reifier = null; - if (definition instanceof DeadLetterChannelConfiguration) { - reifier = ERROR_HANDLERS.get(DeadLetterChannelConfiguration.class); - } else if (definition instanceof DefaultErrorHandlerConfiguration) { - reifier = ERROR_HANDLERS.get(DefaultErrorHandlerConfiguration.class); - } else if (definition instanceof ErrorHandlerRefConfiguration) { - reifier = ERROR_HANDLERS.get(ErrorHandlerRefConfiguration.class); - } else if (definition instanceof NoErrorHandlerConfiguraiton) { - reifier = ERROR_HANDLERS.get(NoErrorHandlerConfiguraiton.class); + + // custom error handlers is registered by class + reifier = ERROR_HANDLERS.get(definition.getClass()); + + if (reifier == null) { + // out of the box error handlers from camel-core + if (definition instanceof DeadLetterChannelConfiguration) { + reifier = ERROR_HANDLERS.get(DeadLetterChannelConfiguration.class); + } else if (definition instanceof DefaultErrorHandlerConfiguration) { + reifier = ERROR_HANDLERS.get(DefaultErrorHandlerConfiguration.class); + } else if (definition instanceof ErrorHandlerRefConfiguration) { + reifier = ERROR_HANDLERS.get(ErrorHandlerRefConfiguration.class); + } else if (definition instanceof NoErrorHandlerConfiguraiton) { + reifier = ERROR_HANDLERS.get(NoErrorHandlerConfiguraiton.class); + } } if (reifier != null) { return reifier.apply(route, definition);