Last active
August 29, 2015 14:12
-
-
Save makuk66/20b04e4a8e4ff682714f to your computer and use it in GitHub Desktop.
fix solrResourceLoader for https://issues.apache.org/jira/browse/SOLR-6887. This patch is placed in the public domain.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java | |
index 9cbd048..86902c4 100644 | |
--- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java | |
+++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java | |
@@ -175,21 +175,41 @@ public class SolrResourceLoader implements ResourceLoader,Closeable | |
*/ | |
void addToClassLoader(final String baseDir, final FileFilter filter, boolean quiet) { | |
File base = FileUtils.resolvePath(new File(getInstanceDir()), baseDir); | |
- if (base != null && base.exists() && base.isDirectory()) { | |
- File[] files = base.listFiles(filter); | |
- if (files == null || files.length == 0) { | |
- if (!quiet) { | |
- log.warn("No files added to classloader from lib: " | |
- + baseDir + " (resolved as: " + base.getAbsolutePath() + ")."); | |
- } | |
- } else { | |
- this.classLoader = replaceClassLoader(classLoader, base, filter); | |
+ if (base == null) { | |
+ if (!quiet) { | |
+ log.warn("Can not add \"" + baseDir + "\"; resolvePath relative to \"" + getInstanceDir() + "\" returned null"); | |
} | |
- } else { | |
+ return; | |
+ } | |
+ File canonical; | |
+ try { | |
+ canonical = base.getCanonicalFile(); | |
+ } | |
+ catch(IOException ioe) { | |
+ log.warn("Can not add \"" + baseDir + "\"; cannot obtain canonical file"); | |
+ return; | |
+ } | |
+ base = canonical; | |
+ if (!base.exists()) { | |
if (!quiet) { | |
- log.warn("Can't find (or read) directory to add to classloader: " | |
- + baseDir + " (resolved as: " + base.getAbsolutePath() + ")."); | |
+ log.warn("Can not add \"" + baseDir + "\": \"" + base.getAbsolutePath() + "\" does not exist"); | |
} | |
+ return; | |
+ } | |
+ if (!base.isDirectory()) { | |
+ if (!quiet) { | |
+ log.warn("Can not add \"" + baseDir + "\": \"" + base.getAbsolutePath() + "\" is not a directory"); | |
+ } | |
+ return; | |
+ } | |
+ File[] files = base.listFiles(filter); | |
+ if (files == null || files.length == 0) { | |
+ if (!quiet) { | |
+ log.warn("No files added to classloader from lib: " | |
+ + baseDir + " (resolved as: " + base.getAbsolutePath() + ")."); | |
+ } | |
+ } else { | |
+ this.classLoader = replaceClassLoader(classLoader, base, filter); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment