Uploaded image for project: 'WS-Commons'
  1. WS-Commons
  2. WSCOMMONS-570

resolved schema cache should use normalized schema url for schema key

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • XmlSchema 1.4.6
    • None
    • XmlSchema
    • 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)

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            brianitko Brian McDonald
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified