Apache Lucene open-source search software
SOLR-1656: Fix XInclude xi:fallback by throwing IOException instead of RuntimeException from ResourceLoader
Uwe Schindlerd45074306e6d
diff --git a/solr/src/common/org/apache/solr/common/util/SystemIdResolver.java b/solr/src/common/org/apache/solr/common/util/SystemIdResolver.javaindex ab76b2202e4..b396735df90 100644--- a/solr/src/common/org/apache/solr/common/util/SystemIdResolver.java+++ b/solr/src/common/org/apache/solr/common/util/SystemIdResolver.java@@ -133,10 +133,15 @@ public final class SystemIdResolver implements EntityResolver, EntityResolver2 {if (!RESOURCE_LOADER_AUTHORITY_ABSOLUTE.equals(authority)) {path = path.substring(1);}- final InputSource is = new InputSource(loader.openResource(path));- is.setSystemId(uri.toASCIIString());- is.setPublicId(publicId);- return is;+ try {+ final InputSource is = new InputSource(loader.openResource(path));+ is.setSystemId(uri.toASCIIString());+ is.setPublicId(publicId);+ return is;+ } catch (RuntimeException re) {+ // unfortunately XInclude fallback only works with IOException, but openResource() never throws that one+ throw (IOException) (new IOException(re.getMessage()).initCause(re));+ }} else {// resolve all other URIs using the standard resolverreturn null;diff --git a/solr/src/test-files/solr/conf/solrconfig-xinclude.xml b/solr/src/test-files/solr/conf/solrconfig-xinclude.xmlindex c7d4b42f2a9..0486b696f4a 100644--- a/solr/src/test-files/solr/conf/solrconfig-xinclude.xml+++ b/solr/src/test-files/solr/conf/solrconfig-xinclude.xml@@ -20,5 +20,9 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>- <xi:include href="solrconfig-reqHandler.incl" xmlns:xi="http://www.w3.org/2001/XInclude"/>+ <xi:include href="foobar-missing.xml" xmlns:xi="http://www.w3.org/2001/XInclude">+ <xi:fallback>+ <xi:include href="solrconfig-reqHandler.incl" xmlns:xi="http://www.w3.org/2001/XInclude"/>+ </xi:fallback>+ </xi:include></config>