mirror of https://github.com/apache/lucene.git
SOLR-6179: Fix unit test breakage by using InMemory storage if config dir is not writable.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1607128 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f512330b14
commit
5c75969c04
|
@ -117,7 +117,23 @@ public abstract class ManagedResourceStorage {
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue