You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2013/04/03 08:41:55 UTC
svn commit: r1463837 - in /lucene/dev/branches/branch_4x: ./ solr/
solr/core/ solr/core/src/java/org/apache/solr/core/ solr/example/
solr/example/solr/collection1/conf/
Author: dweiss
Date: Wed Apr 3 06:41:55 2013
New Revision: 1463837
URL: http://svn.apache.org/r1463837
Log:
SOLR-4653: Solr configuration should log inaccessible/ non-existent relative paths in lib dir=...
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrConfig.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
lucene/dev/branches/branch_4x/solr/example/ (props changed)
lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1463837&r1=1463836&r2=1463837&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Wed Apr 3 06:41:55 2013
@@ -138,6 +138,9 @@ Optimizations
Other Changes
----------------------
+* SOLR-4653: Solr configuration should log inaccessible/ non-existent relative paths in lib
+ dir=... (Dawid Weiss)
+
* SOLR-4317: SolrTestCaseJ4: Can't avoid "collection1" convention (Tricia Jenkins, via Erick Erickson)
* SOLR-4571: SolrZkClient#setData should return Stat object. (Mark Miller)
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrConfig.java?rev=1463837&r1=1463836&r2=1463837&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrConfig.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrConfig.java Wed Apr 3 06:41:55 2013
@@ -462,10 +462,10 @@ public class SolrConfig extends Config {
String baseDir = DOMUtil.getAttr(node, "dir");
String path = DOMUtil.getAttr(node, "path");
if (null != baseDir) {
- // :TODO: add support for a simpler 'glob' mutually eclusive of regex
+ // :TODO: add support for a simpler 'glob' mutually exclusive of regex
String regex = DOMUtil.getAttr(node, "regex");
FileFilter filter = (null == regex) ? null : new RegexFileFilter(regex);
- getResourceLoader().addToClassLoader(baseDir, filter);
+ getResourceLoader().addToClassLoader(baseDir, filter, false);
} else if (null != path) {
getResourceLoader().addToClassLoader(path);
} else {
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java?rev=1463837&r1=1463836&r2=1463837&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java Wed Apr 3 06:41:55 2013
@@ -111,7 +111,7 @@ public class SolrResourceLoader implemen
}
this.classLoader = createClassLoader(null, parent);
- addToClassLoader("./lib/", null);
+ addToClassLoader("./lib/", null, true);
reloadLuceneSPI();
this.coreProperties = coreProperties;
}
@@ -135,17 +135,35 @@ public class SolrResourceLoader implemen
* only be called prior to using this ResourceLoader to get any resources, otherwise
* it's behavior will be non-deterministic. You also have to {link @reloadLuceneSPI}
* before using this ResourceLoader.
+ *
+ * <p>This method will quietly ignore missing or non-directory <code>baseDir</code>
+ * folder.
*
* @param baseDir base directory whose children (either jars or directories of
* classes) will be in the classpath, will be resolved relative
* the instance dir.
* @param filter The filter files must satisfy, if null all files will be accepted.
+ * @param quiet Be quiet if baseDir does not point to a directory or if no file is
+ * left after applying the filter.
*/
- void addToClassLoader(final String baseDir, final FileFilter filter) {
+ void addToClassLoader(final String baseDir, final FileFilter filter, boolean quiet) {
File base = FileUtils.resolvePath(new File(getInstanceDir()), baseDir);
- this.classLoader = replaceClassLoader(classLoader, base, filter);
+ if (base != null && base.exists() && base.isDirectory()) {
+ File[] files = base.listFiles(filter);
+ if (!quiet && (files == null || files.length == 0)) {
+ log.warn("No files added to classloader from lib: "
+ + baseDir + " (resolved as: " + base.getAbsolutePath() + ").");
+ } else {
+ this.classLoader = replaceClassLoader(classLoader, base, filter);
+ }
+ } else {
+ if (!quiet) {
+ log.warn("Can't find (or read) directory to add to classloader: "
+ + baseDir + " (resolved as: " + base.getAbsolutePath() + ").");
+ }
+ }
}
-
+
/**
* Adds the specific file/dir specified to the ClassLoader used by this
* ResourceLoader. This method <b>MUST</b>
@@ -174,7 +192,7 @@ public class SolrResourceLoader implemen
/**
* Reloads all Lucene SPI implementations using the new classloader.
* This method must be called after {@link #addToClassLoader(String)}
- * and {@link #addToClassLoader(String,FileFilter)} before using
+ * and {@link #addToClassLoader(String,FileFilter,boolean)} before using
* this ResourceLoader.
*/
void reloadLuceneSPI() {
Modified: lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml?rev=1463837&r1=1463836&r2=1463837&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/solrconfig.xml Wed Apr 3 06:41:55 2013
@@ -82,9 +82,9 @@
<lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />
<!-- If a 'dir' option (with or without a regex) is used and nothing
- is found that matches, it will be ignored
+ is found that matches, a warning will be logged.
-->
- <lib dir="/total/crap/dir/ignored" />
+ <lib dir="/non/existent/dir/yields/warning" />
<!-- an exact 'path' can be used instead of a 'dir' to specify a
specific jar file. This will cause a serious error to be logged