You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2014/07/01 18:06:59 UTC
svn commit: r1607128 -
/lucene/dev/trunk/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java
Author: thelabdude
Date: Tue Jul 1 16:06:59 2014
New Revision: 1607128
URL: http://svn.apache.org/r1607128
Log:
SOLR-6179: Fix unit test breakage by using InMemory storage if config dir is not writable.
Modified:
lucene/dev/trunk/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java?rev=1607128&r1=1607127&r2=1607128&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java Tue Jul 1 16:06:59 2014
@@ -117,7 +117,23 @@ public abstract class ManagedResourceSto
if (storageIO instanceof FileStorageIO) {
// using local fs, if storageDir is not set in the solrconfig.xml, assume the configDir for the core
if (initArgs.get(STORAGE_DIR_INIT_ARG) == null) {
- initArgs.add(STORAGE_DIR_INIT_ARG, resourceLoader.getConfigDir());
+ File configDir = new File(resourceLoader.getConfigDir());
+ boolean hasAccess = false;
+ try {
+ hasAccess = configDir.isDirectory() && configDir.canWrite();
+ } catch (java.security.AccessControlException ace) {}
+
+ if (hasAccess) {
+ initArgs.add(STORAGE_DIR_INIT_ARG, configDir.getAbsolutePath());
+ } else {
+ // most likely this is because of a unit test
+ // that doesn't have write-access to the config dir
+ // while this failover approach is not ideal, it's better
+ // than causing the core to fail esp. if managed resources aren't being used
+ log.warn("Cannot write to config directory "+configDir.getAbsolutePath()+
+ "; switching to use InMemory storage instead.");
+ storageIO = new ManagedResourceStorage.InMemoryStorageIO();
+ }
}
}