Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
XmlSchema 1.4.6
-
None
-
None
Description
Currently in 1.4.6, 1.4.7 and 2.0 the schema key used to index the resolved schema cache is
String schemaKey = targetNamespace + schemaLocation + baseUri;
This does not properly handle caching schemas where the schemaLocation is fully qualified but referenced from different baseUris (this is a common practice in .Net WSDL schemas).
I recommend building a URL from the schemaLocation and baseUri to generate a normalized schema URL that can be used when caching the schema.
Also recommend using a Map<String, Map<String, SoftReference>> creating a Map from targetNamesapce to a Map from schemaURL to SoftReference to a XmlSchema object. It makes debugging simpler with shorter keys and grouping by namespace.
Below is an example code change for 1.4.6. Let me know if you need a patch for 1.4.7 or 2.0
try
{ java.net.URL baseURL = new java.net.URL(baseUri); java.net.URL schemaURL = new java.net.URL(baseURL, schemaLocation); schemaKey = schemaURL.toURI().toURL().toString(); }catch (MalformedURLException e)
{ System.out.println(e); } catch (URISyntaxException e) { System.out.println(e); } if (resolvedSchemas.get(targetNamespace) != null) {
java.util.Map<String,SoftReference> map = (java.util.Map<String,SoftReference>)resolvedSchemas.get(targetNamespace);
SoftReference softref = map.get(schemaKey);
if (softref != null) {
XmlSchema resolvedSchema = (XmlSchema)softref.get();
if (resolvedSchema != null)
}
}
...
XmlSchema readSchema = collection.read(source, null, validator);
if (resolvedSchemas != null) {
if (resolvedSchemas.get(targetNamespace) == null)
java.util.Map<String, SoftReference> map = (java.util.Map<String, SoftReference>) resolvedSchemas.get(targetNamespace);
map.put(schemaKey, new SoftReference(readSchema));
}