From 2103fde78f43cd9b446ece59ee0b1fb5c53724df Mon Sep 17 00:00:00 2001 From: Rob Harrop Date: Tue, 8 Sep 2009 08:37:10 +0000 Subject: [PATCH] fix to resource handling in PluggableSchemaResolver git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1842 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../factory/xml/PluggableSchemaResolver.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java index 3d27aa11432..d331ac39033 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java @@ -17,6 +17,7 @@ package org.springframework.beans.factory.xml; import java.io.IOException; +import java.io.FileNotFoundException; import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; @@ -99,23 +100,30 @@ public class PluggableSchemaResolver implements EntityResolver { this.schemaMappingsLocation = schemaMappingsLocation; } - public InputSource resolveEntity(String publicId, String systemId) throws IOException { if (logger.isTraceEnabled()) { logger.trace("Trying to resolve XML entity with public id [" + publicId + "] and system id [" + systemId + "]"); } + if (systemId != null) { String resourceLocation = getSchemaMappings().get(systemId); if (resourceLocation != null) { Resource resource = new ClassPathResource(resourceLocation, this.classLoader); - InputSource source = new InputSource(resource.getInputStream()); - source.setPublicId(publicId); - source.setSystemId(systemId); - if (logger.isDebugEnabled()) { - logger.debug("Found XML schema [" + systemId + "] in classpath: " + resourceLocation); + try { + InputSource source = new InputSource(resource.getInputStream()); + source.setPublicId(publicId); + source.setSystemId(systemId); + if (logger.isDebugEnabled()) { + logger.debug("Found XML schema [" + systemId + "] in classpath: " + resourceLocation); + } + return source; + } + catch (FileNotFoundException ex) { + if (logger.isDebugEnabled()) { + logger.debug("Couldn't find XML schema [" + systemId + "]: " + resource, ex); + } } - return source; } } return null;