You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Sydney Henrard (Jira)" <ji...@apache.org> on 2023/02/21 18:02:00 UTC

[jira] [Created] (CAMEL-19081) Start a route with aggregation fails due to NPE in AggregateProcessor

Sydney Henrard created CAMEL-19081:
--------------------------------------

             Summary: Start a route with aggregation fails due to NPE in AggregateProcessor
                 Key: CAMEL-19081
                 URL: https://issues.apache.org/jira/browse/CAMEL-19081
             Project: Camel
          Issue Type: Bug
    Affects Versions: 3.20.1
            Reporter: Sydney Henrard


In my application I have a route with an aggregation using an aggregation repository ClusteredJdbcAggregationRepository and completionTimeout. This route is part of a micro service that can be scaled. From time to time, the micro service does not start due to a NPE:
{code:java}
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.camel.Exchange.getProperty(org.apache.camel.ExchangePropertyKey, Object, java.lang.Class)" because "exchange" is null         at org.apache.camel.processor.aggregate.AggregateProcessor.restoreTimeoutMapFromAggregationRepository(AggregateProcessor.java:920) ~[camel-core-processor-3.20.1.jar:3.20.1]  {code}
In my case the exchange is null because it has already been processed by one of the micro service instance.
 The relevant code is in [https://github.com/apache/camel/blob/camel-3.20.1/core/camel-core-processor/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java#L920]
{code:java}
for (String key : keys) {     
    Exchange exchange = aggregationRepository.get(camelContext, key);     // grab the timeout value     
    long timeout = exchange.getProperty(ExchangePropertyKey.AGGREGATED_TIMEOUT, 0L, long.class);{code}
 
The null check is missing. It's not a problem when aggregation repository is not shared among instance like LevelDB, but it is when it's shared like JDBC.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)