CAMEL-4817 properly close datastore on doStop in GoraComponent

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

Branch: refs/heads/master
Commit: 4475631f819f9586690a361a58768df4d9d654e1
Parents: 2cc566c
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Mon Dec 9 10:30:47 2013 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Tue May 27 16:11:56 2014 +0800

----------------------------------------------------------------------
 .../camel/component/gora/GoraComponent.java     | 26 +++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4475631f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java
 
b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java
index 0a162fd..6a2a063 100644
--- 
a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java
+++ 
b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java
@@ -55,12 +55,11 @@ public class GoraComponent extends DefaultComponent {
      *
      * Initialize class and create DataStore instance
      *
-     * @param config  component configuration
+     * @param config component configuration
      * @throws IOException
      */
     private void init(final GoraConfiguration config) throws IOException {
-
-        this.configuration = new Configuration();
+        
         this.goraProperties = DataStoreFactory.createProps();
 
         this.dataStore = 
DataStoreFactory.getDataStore(goraProperties.getProperty(GORA_DEFAULT_DATASTORE_KEY,
@@ -101,5 +100,26 @@ public class GoraComponent extends DefaultComponent {
 
         return dataStore;
     }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void doStart() throws Exception {
+        if (configuration == null) {
+            configuration = new Configuration();
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void doStop() throws Exception {
+
+        if (dataStore != null) {
+            dataStore.close();
+        }
+    }
 
 }
\ No newline at end of file

Reply via email to