From e62461d808057bb56538daabe6925e2b4ce0522f Mon Sep 17 00:00:00 2001 From: Prasanth Pagolu Date: Mon, 15 May 2017 13:55:51 +0100 Subject: [PATCH] CAMEL-11234: NullPointerException while trying to get the Route Status on startup --- .../org/apache/camel/impl/DefaultCamelContext.java | 3 ++- .../OnExceptionGlobalScopedRecursionTest.java | 12 ++++++------ .../onexception/OnExceptionRecursionTest.java | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java index 82644d5b36ee7..65c181df80710 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java @@ -3041,7 +3041,8 @@ public void start() throws Exception { // count how many routes are actually started int started = 0; for (Route route : getRoutes()) { - if (getRouteStatus(route.getId()).isStarted()) { + ServiceStatus status = getRouteStatus(route.getId()); + if (status != null && status.isStarted()) { started++; } } diff --git a/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalScopedRecursionTest.java b/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalScopedRecursionTest.java index 417d4faabc8d9..37f6088d83ce9 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalScopedRecursionTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionGlobalScopedRecursionTest.java @@ -42,7 +42,7 @@ public void configure() throws Exception { .to("mock:c") .log("onException") .throwException(new NullPointerException("A NPE error here")) - .end(); + .end(); from("direct:test") .to("mock:a") @@ -78,7 +78,7 @@ public void configure() throws Exception { .to("mock:c") .log("onException") .throwException(new NullPointerException("A NPE error here")) - .end(); + .end(); from("direct:test") .to("mock:a") @@ -114,7 +114,7 @@ public void configure() throws Exception { .to("mock:c") .log("onException") .to("direct:error") - .end(); + .end(); from("direct:test") .to("mock:a") @@ -157,7 +157,7 @@ public void configure() throws Exception { .to("mock:c") .log("onException") .to("direct:error") - .end(); + .end(); from("direct:test") .to("mock:a") @@ -199,7 +199,7 @@ public void configure() throws Exception { .to("mock:c") .log("onException") .to("direct:error") - .end(); + .end(); from("direct:test") .to("mock:a") @@ -239,7 +239,7 @@ public void configure() throws Exception { .to("mock:c") .log("onException") .to("direct:error") - .end(); + .end(); from("direct:test") .to("mock:a") diff --git a/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRecursionTest.java b/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRecursionTest.java index bac6e4096cfef..d832296ee5baa 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRecursionTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRecursionTest.java @@ -68,7 +68,7 @@ public void configure() throws Exception { assertEquals("Bad state", ise.getMessage()); } - assertMockEndpointsSatisfied(); + assertMockEndpointsSatisfied(); } public void testRecursionDirectNoErrorHandler() throws Exception {