FELIX-1995: Fix synchronization issue which cause two spring osgi listeners to be registered and created

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@909302 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/SpringStateListenerFactory.java b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/SpringStateListenerFactory.java
index b9f8a24..9a0069c 100644
--- a/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/SpringStateListenerFactory.java
+++ b/karaf/shell/osgi/src/main/java/org/apache/felix/karaf/shell/osgi/SpringStateListenerFactory.java
@@ -46,7 +46,7 @@
     }
 
     public void init() {
-        createListener();
+        getListener();
     }
 
     public void destroy() throws Exception {
@@ -55,7 +55,7 @@
         }
     }
 
-    public BundleStateListener getListener() {
+    public synchronized BundleStateListener getListener() {
         if (listener == null) {
             listener = createListener();
         }