Author: shashank
Date: Wed Feb  3 11:05:24 2016
New Revision: 1728296

URL: http://svn.apache.org/viewvc?rev=1728296&view=rev
Log:
OAK-3253 Support caching in FileDataStoreService

Removed throws RepositoryException & introduced Preconditions.null check

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java?rev=1728296&r1=1728295&r2=1728296&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java
 Wed Feb  3 11:05:24 2016
@@ -19,6 +19,7 @@
 
 package org.apache.jackrabbit.oak.plugins.blob.datastore;
 
+import com.google.common.base.Preconditions;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
 import org.apache.jackrabbit.core.data.CachingFDS;
@@ -40,22 +41,21 @@ public class FileDataStoreService extend
     public static final String PATH = "path";
 
     @Override
-    protected DataStore createDataStore(ComponentContext context, Map<String, 
Object> config) throws RepositoryException {
+    protected DataStore createDataStore(ComponentContext context, Map<String, 
Object> config) {
 
         long cacheSize = PropertiesUtil.toLong(config.get(CACHE_SIZE), 0L);
         // return CachingFDS when cacheSize > 0
         if (cacheSize > 0) {
-            String fsBackendPath = PropertiesUtil.toString(config.get(PATH), 
"");
-            if ("".equals(fsBackendPath)) {
-                throw new RepositoryException("Cannot create 
FileDataStoreService with caching. [{path}] property not configured.");
-            }
+            String fsBackendPath = PropertiesUtil.toString(config.get(PATH), 
null);
+            Preconditions.checkNotNull(fsBackendPath, "Cannot create " +
+                    "FileDataStoreService with caching. [{path}] property not 
configured.");
             CachingFDS dataStore = new CachingFDS();
             config.remove(PATH);
             config.remove(CACHE_SIZE);
             config.put(FS_BACKEND_PATH, fsBackendPath);
             config.put("cacheSize", cacheSize);
-            String cachePath = PropertiesUtil.toString(config.get(CACHE_PATH), 
"");
-            if (!"".equals(cachePath)) {
+            String cachePath = PropertiesUtil.toString(config.get(CACHE_PATH), 
null);
+            if (cachePath != null) {
                 config.remove(CACHE_PATH);
                 config.put(PATH, cachePath);
             }


Reply via email to