Fixed potential NPE in camel-stomp

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/90ece125
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/90ece125
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/90ece125

Branch: refs/heads/camel-2.18.x
Commit: 90ece12527c6f1fc0fe692546a182d993a7eca27
Parents: 3249253
Author: Claus Ibsen <davscl...@apache.org>
Authored: Sat Oct 15 15:29:25 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Sat Oct 22 11:44:34 2016 +0200

----------------------------------------------------------------------
 .../camel/component/stomp/StompComponent.java   | 23 +-------------------
 1 file changed, 1 insertion(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/90ece125/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java
 
b/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java
index d27c16a..3684345 100644
--- 
a/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java
+++ 
b/components/camel-stomp/src/main/java/org/apache/camel/component/stomp/StompComponent.java
@@ -27,7 +27,7 @@ public class StompComponent extends UriEndpointComponent {
     /**
      * To use the shared stomp configuration
      */
-    private StompConfiguration configuration;
+    private StompConfiguration configuration = new StompConfiguration();
 
     /**
      * The URI of the Stomp broker to connect to
@@ -69,15 +69,6 @@ public class StompComponent extends UriEndpointComponent {
         return endpoint;
     }
 
-    @Override
-    protected void doStart() throws Exception {
-        super.doStart();
-
-        if (configuration == null) {
-            configuration = new StompConfiguration();
-        }
-    }
-
     public StompConfiguration getConfiguration() {
         return configuration;
     }
@@ -93,9 +84,6 @@ public class StompComponent extends UriEndpointComponent {
      * The URI of the Stomp broker to connect to
      */
     public void setBrokerURL(String brokerURL) {
-        if (configuration == null) {
-            configuration = new StompConfiguration();
-        }
         configuration.setBrokerURL(brokerURL);
     }
 
@@ -103,9 +91,6 @@ public class StompComponent extends UriEndpointComponent {
      * The username
      */
     public void setLogin(String login) {
-        if (configuration == null) {
-            configuration = new StompConfiguration();
-        }
         configuration.setLogin(login);
     }
 
@@ -113,9 +98,6 @@ public class StompComponent extends UriEndpointComponent {
      * The password
      */
     public void setPasscode(String passcode) {
-        if (configuration == null) {
-            configuration = new StompConfiguration();
-        }
         configuration.setPasscode(passcode);
     }
     
@@ -123,9 +105,6 @@ public class StompComponent extends UriEndpointComponent {
      * The virtual host
      */
     public void setHost(String host) {
-        if (configuration == null) {
-            configuration = new StompConfiguration();
-        }
         configuration.setHost(host);
     }
 }

Reply via email to