You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by "Brian McDonald (JIRA)" <ji...@apache.org> on 2011/08/04 23:05:27 UTC

[jira] [Created] (WSCOMMONS-570) resolved schema cache should use normalized schema url for schema key

resolved schema cache should use normalized schema url for schema key
---------------------------------------------------------------------

                 Key: WSCOMMONS-570
                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-570
             Project: WS-Commons
          Issue Type: Improvement
          Components: XmlSchema
    Affects Versions: XmlSchema 1.4.6
            Reporter: Brian McDonald


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) {
                        return resolvedSchema;
                    }
                }
            }
...

                    XmlSchema readSchema = collection.read(source, null, validator);
                    if (resolvedSchemas != null) {
                        if (resolvedSchemas.get(targetNamespace) == null) {
                            resolvedSchemas.put(targetNamespace, new java.util.HashMap<String, SoftReference>());
                        }
                        java.util.Map<String, SoftReference> map = (java.util.Map<String, SoftReference>) resolvedSchemas.get(targetNamespace);
                        map.put(schemaKey, new SoftReference(readSchema));
                    }


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org