I'm using Camel 2.4.10.  I'm get a NPE in RouteContextProcessor at line 42:

    29  public class RouteContextProcessor extends DelegateAsyncProcessor {
...
    38      @Override
    39      protected boolean processNext(final Exchange exchange, final
AsyncCallback callback) {
    40          // push the current route context
    41          if (exchange.getUnitOfWork() != null) {
    42              exchange.getUnitOfWork().pushRouteContext(routeContext);
    43          }

I am able to demonstrate that even though the test in line 41 is true,
getUnitOfWork() in null in line 43.  I do this by instrumenting the code as
follows:

   @Override                                                                    
                                                                                
                                             
    protected boolean processNext(final Exchange exchange, final
AsyncCallback callback) {
        // push the current route context                                       
                                                                                
                                              
        try {
        if (exchange.getUnitOfWork() != null) {
            exchange.getUnitOfWork().pushRouteContext(routeContext);
        }
        } catch (Exception e) {
            System.out.println("********************\n"+exchange);              
                                                                                
                                              
            System.out.println(exchange.getUnitOfWork());
            e.printStackTrace();
            System.exit(1);

        }

And I can clearly see the null value.  This implies to me somebody else has
a reference to the same exchange object and is changing it between lines 42
and line 43.  This only happens occasionally (1 in 1000 times).

My code has 10 threads, so I wouldn't be surprised if it was my problem, but
I just can't see it.  I am not doing anything with the UnitOfWork in an
exchange.  At most, I change the body of the Message and perhaps the
headers.

This is very difficult to debug because it happens so infrequently.  Does
anyone have a suggestion that could help me?




--
View this message in context: 
http://camel.465427.n5.nabble.com/NPE-in-RouteContextProcessor-tp5716620.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to