SOLR-1656: Fix XInclude xi:fallback by throwing IOException instead of RuntimeException from ResourceLoader

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1075079 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2011-02-27 15:40:57 +00:00
parent 638767c9ac
commit d45074306e
2 changed files with 14 additions and 5 deletions

View File

@ -133,10 +133,15 @@ public final class SystemIdResolver implements EntityResolver, EntityResolver2 {
if (!RESOURCE_LOADER_AUTHORITY_ABSOLUTE.equals(authority)) { if (!RESOURCE_LOADER_AUTHORITY_ABSOLUTE.equals(authority)) {
path = path.substring(1); path = path.substring(1);
} }
final InputSource is = new InputSource(loader.openResource(path)); try {
is.setSystemId(uri.toASCIIString()); final InputSource is = new InputSource(loader.openResource(path));
is.setPublicId(publicId); is.setSystemId(uri.toASCIIString());
return is; 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 { } else {
// resolve all other URIs using the standard resolver // resolve all other URIs using the standard resolver
return null; return null;

View File

@ -20,5 +20,9 @@
<config> <config>
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion> <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> </config>