FELIX-3334 applied the patch with a slight change

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1299663 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java b/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java
index b445199..f5b2472 100644
--- a/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java
+++ b/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.prefs;
 
+import org.osgi.service.prefs.BackingStoreException;
+
 
 /**
  * Get the backing store.
@@ -27,5 +29,5 @@
     /**
      * Return the current backing store.
      */
-    BackingStore getStore();
+    BackingStore getStore() throws BackingStoreException;
 }
diff --git a/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java b/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java
index 458ce6a..555ded5 100644
--- a/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java
+++ b/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java
@@ -193,30 +193,36 @@
     /**
      * @see org.apache.felix.prefs.BackingStoreManager#getStore()
      */
-    public BackingStore getStore() {
-        if (this.storeTracker == null) {
-            // We're being stopped already...
-            return null;
+    public BackingStore getStore() throws BackingStoreException {
+        BackingStore service = null;
+        ServiceTracker storeTracker = this.storeTracker;
+
+        // Only possible if we're not stopped already...
+        if (storeTracker != null) {
+	        // has the service changed?
+	        int currentCount = storeTracker.getTrackingCount();
+	        service = (BackingStore) storeTracker.getService();
+	        if (service != null && this.storeTrackingCount < currentCount) {
+	            this.storeTrackingCount = currentCount;
+	            this.cleanupStore(service);
+	        }
+	        if (service == null) {
+	            // no service available use default store
+	            if (this.defaultStore == null) {
+	                synchronized (this) {
+	                    if (this.defaultStore == null) {
+	                        this.defaultStore = new DataFileBackingStoreImpl(this.context);
+	                        this.cleanupStore(this.defaultStore);
+	                    }
+	                }
+	            }
+	            service = this.defaultStore;
+	        }
         }
 
-        // has the service changed?
-        int currentCount = this.storeTracker.getTrackingCount();
-        BackingStore service = (BackingStore) this.storeTracker.getService();
-        if (service != null && this.storeTrackingCount < currentCount) {
-            this.storeTrackingCount = currentCount;
-            this.cleanupStore(service);
-        }
         if (service == null) {
-            // no service available use default store
-            if (this.defaultStore == null) {
-                synchronized (this) {
-                    if (this.defaultStore == null) {
-                        this.defaultStore = new DataFileBackingStoreImpl(this.context);
-                        this.cleanupStore(this.defaultStore);
-                    }
-                }
-            }
-            service = this.defaultStore;
+            // (still) no service available; cannot fulfill this request...
+            throw new BackingStoreException("No backing store!");
         }
 
         return service;