Forum Home » Fuse Distributions » Fuse ESB

Thread: Route with aggregate complete predicate which throws null exception

 

Permlink Replies: 3 - Last Post: May 11, 2012 4:35 AM Last Post By: davsclaus
garethahealy

Posts: 88
Registered: 05/01/12
Route with aggregate complete predicate which throws null exception
Posted: May 4, 2012 12:04 PM
  Click to reply to this thread Reply
I have a route which has an aggregate on it.

<aggregate strategyRef="psvProductAggregationStrategy">
<correlationExpression>
<header>psvProductId</header>
</correlationExpression>
<completionPredicate>
<method bean="psvProductAggregationStrategy" method="isCompleted"/>
</completionPredicate>
<to uri="direct:transformToSimpleProduct"/>
</aggregate>

The "isComplete" method is below:

public Boolean isCompleted() {
Boolean isComplete = this.hasMasterProductRow && this.hasProductMediaRow && this.hasProductExtDataRow
&& this.hasProductAttributeRow && this.hasProductAttributePriceRow;

return isComplete;
}

All the "has..." are booleans so i am very confused as to why i get the below exception.

11:52:34,600 | ERROR | ucts - example 1 | DefaultErrorHandler | ? ? | 89 - org.apache.camel.camel-core - 2.8.0.fuse-01-13 | Failed delivery for exchangeId: ID-BHWKS157-35881-1336127147367-6-16. Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException
java.lang.NullPointerException
at com.boohoo.esb.products.sage.internal.helpers.PsvProductAggregationStrategy.isCompleted(PsvProductAggregationStrategy.java:87)293:boohoo-esb-products-sage-internal:1.0.0.SNAPSHOT
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method):1.6.0_29
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39):1.6.0_29
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25):1.6.0_29
at java.lang.reflect.Method.invoke(Method.java:597):1.6.0_29
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:329)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:231)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:169)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:74)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:139)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:92)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.language.bean.BeanExpression.matches(BeanExpression.java:106)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.aggregate.AggregateProcessor.isCompleted(AggregateProcessor.java:287)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.aggregate.AggregateProcessor.doAggregation(AggregateProcessor.java:241)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.aggregate.AggregateProcessor.process(AggregateProcessor.java:189)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.fabric.FabricTraceProcessor.process(FabricTraceProcessor.java:59)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:318)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:209)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:306)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.Pipeline.process(Pipeline.java:116)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.Pipeline.process(Pipeline.java:79)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:139)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:106)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:353)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:176)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:137)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:138)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:90)89:org.apache.camel.camel-core:2.8.0.fuse-01-13
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441):1.6.0_29
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317):1.6.0_29
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150):1.6.0_29
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98):1.6.0_29
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180):1.6.0_29
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204):1.6.0_29
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886):1.6.0_29
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908):1.6.0_29
at java.lang.Thread.run(Thread.java:662):1.6.0_29

davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Route with aggregate complete predicate which throws null exception
Posted: May 4, 2012 2:03 PM   in response to: garethahealy in response to: garethahealy
  Click to reply to this thread Reply
If you use java.lang.Boolean, then if that is null, you get a NullPointerException when you test the boolean as if they were primitive booleans.

You would need to do a != null check as well. Or use primitive booleans, or adjust the is method to check for != null.

public Boolean isFoo() {
return foo != null && foo;
}

We do this ^^^ in Camel, for the boolean types we have in the route models.
garethahealy

Posts: 88
Registered: 05/01/12
Re: Route with aggregate complete predicate which throws null exception
Posted: May 10, 2012 4:27 PM   in response to: davsclaus in response to: davsclaus
  Click to reply to this thread Reply
Thanks. Didnt think of that - i come from C# so thought it was very strange/didnt expect that.

Edited by: garethahealy on May 10, 2012 4:27 PM
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Route with aggregate complete predicate which throws null exception
Posted: May 11, 2012 4:35 AM   in response to: garethahealy in response to: garethahealy
  Click to reply to this thread Reply
Yep the auto boxing in Java is a bit strange.