Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastCamelContext.clearModel() causes NPEs at runtime #69

Closed
ppalaga opened this issue Jul 15, 2019 · 6 comments
Closed

FastCamelContext.clearModel() causes NPEs at runtime #69

ppalaga opened this issue Jul 15, 2019 · 6 comments
Assignees

Comments

@ppalaga
Copy link
Contributor

ppalaga commented Jul 15, 2019

FastCamelContext.clearModel() was introducted with the upgrade to Camel 3.0.0-M3. It causes some NPEs at runtime, e.g. in org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.lookupErrorHandlerFactory(RouteContext, String, boolean) or in FastCamelRuntime.dumpRoutes() because RouteContext.getRoute() returns null after FastCamelContext.clearModel() was called

@ppalaga
Copy link
Contributor Author

ppalaga commented Jul 15, 2019

Reproducible with the code in #72

@ppalaga
Copy link
Contributor Author

ppalaga commented Aug 22, 2019

Getting back to this one now. So clearing the model causes two known issues: (1) a NPE when calling FastCamelRuntime.dumpRoutes() and (2) a NPE in ErrorHandlerReifier.lookupErrorHandlerFactory(RouteContext, String, boolean)

(1) is, I think, quite harmless. We can either ignore it or find a way how to describe a route without having the RouteDef available, perhaps by storing the description at build time somewhere, e.g. in FastModel.FastRouteContext

(2) is I believe harder to solve. Here is the stack trace from the bean itest after clearModel() was re-activated in FastCamelRuntime.loadRoutes(CamelContext) (see https://github.com/ppalaga/camel-quarkus/tree/i69 ):

19-08-22 14:22:25,519 ERROR [org.apa.cam.pro.err.DefaultErrorHandler] (executor-thread-1) Failed delivery for (MessageId: 13A71AB740722A0-0000000000000001 on ExchangeId: 13A71AB740722A0-0000000000000000). Exhausted after delivery attempt: 1 caught: org.apache.camel.RuntimeCamelException: java.lang.NullPointerException: org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
        at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:52)
        at org.apache.camel.processor.MulticastProcessor.createErrorHandler(MulticastProcessor.java:721)
        at org.apache.camel.processor.MulticastProcessor.createProcessorExchangePair(MulticastProcessor.java:664)
        at org.apache.camel.processor.Splitter$SplitterIterable$1.next(Splitter.java:205)
        at org.apache.camel.processor.Splitter$SplitterIterable$1.next(Splitter.java:158)
        at org.apache.camel.processor.Splitter.createProcessorExchangePairsList(Splitter.java:230)
        at org.apache.camel.processor.Splitter.createProcessorExchangePairs(Splitter.java:124)
        at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:211)
        at org.apache.camel.processor.Splitter.process(Splitter.java:111)
        at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryState.run(RedeliveryErrorHandler.java:480)
        at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:185)
        at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:87)
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:222)
        at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:72)
        at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:189)
        at org.apache.camel.processor.SharedCamelInternalProcessor$1.process(SharedCamelInternalProcessor.java:90)
        at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:77)
        at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:87)
        at org.apache.camel.impl.engine.DefaultProducerCache.send(DefaultProducerCache.java:141)
        at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:163)
        at org.apache.camel.impl.engine.DefaultProducerTemplate.send(DefaultProducerTemplate.java:159)
        at org.apache.camel.impl.engine.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:347)
        at org.apache.camel.quarkus.component.bean.CamelResource.processOrder(CamelResource.java:41)
        at org.apache.camel.quarkus.component.bean.CamelResource_ClientProxy.processOrder(CamelResource_ClientProxy.zig:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:151)
        at org.jboss.resteasy.core.MethodInjectorImpl.lambda$invoke$3(MethodInjectorImpl.java:122)
        at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
        at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:614)
        at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:1983)
        at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:110)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:122)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:594)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:468)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:421)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:423)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:391)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invoke$1(ResourceMethodInvoker.java:365)
        at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:981)
        at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2124)
        at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:110)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:365)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:249)
        at io.quarkus.resteasy.runtime.ResteasyFilter.doFilter(ResteasyFilter.java:30)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1$1.call(UndertowDeploymentRecorder.java:513)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1395)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.NullPointerException
        at org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.lookupErrorHandlerFactory(ErrorHandlerReifier.java:172)
        at org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.lookupErrorHandlerFactory(ErrorHandlerReifier.java:152)
        at org.apache.camel.builder.ErrorHandlerBuilderRef.lookupErrorHandler(ErrorHandlerBuilderRef.java:70)
        at org.apache.camel.builder.ErrorHandlerBuilderRef.createErrorHandler(ErrorHandlerBuilderRef.java:42)
        at org.apache.camel.processor.MulticastProcessor.createErrorHandler(MulticastProcessor.java:704)
        ... 90 more

The question is whether the ErrorHandlerReifier code should (a) really be triggered by a request or (b) if it should have been done during FastCamelRuntime.loadRoutes(CamelContext) before clearModel() is called? WDYT @gnodet @davsclaus @lburgazzoli ?

@ppalaga
Copy link
Contributor Author

ppalaga commented Aug 28, 2019

Agreed with @gnodet that I should create a Camel Jira for this.

@gnodet
Copy link
Contributor

gnodet commented Aug 28, 2019

Right, this definitely needs to be fixed asap in Camel.

@gnodet
Copy link
Contributor

gnodet commented Aug 28, 2019

I've just created https://issues.apache.org/jira/browse/CAMEL-13912 for that, i'll have a look asap.

@gnodet
Copy link
Contributor

gnodet commented Aug 29, 2019

I've commited a fix but testing it in camel-quarkus requires an upgrade to camel 3.0.0-SNAPSHOT / RC1 which is not trivial, so need to work on that first.

@gnodet gnodet self-assigned this Aug 29, 2019
@gnodet gnodet closed this as completed in 30b97e3 Sep 5, 2019
lburgazzoli pushed a commit that referenced this issue Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants