DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10088>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10088

TraverseSchema throws NPE when InputSource has null systemId

           Summary: TraverseSchema throws NPE when InputSource has null
                    systemId
           Product: Xerces-J
           Version: 1.4.4
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Schema-Structures
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


TraverseSchema will throw a NPE in its openRedefinedSchema method if the 
EntityResolver returns an InputSource from its resolveEntity method which has a 
null systemId.

The source code that is causing the problem is:

    private void openRedefinedSchema(Element redefineDecl, SchemaInfo store) 
throws Exception {
        Attr locationAttr = redefineDecl.getAttributeNode
(SchemaSymbols.ATT_SCHEMALOCATION);
        if (locationAttr == null) {
            // REVISIT: Localize
            fRedefineSucceeded = false;
            reportGenericSchemaError("a schemaLocation attribute must be 
specified on a <redefine> element");
            return;
        }
        String location = locationAttr.getValue();

        // expand it before passing it to the parser
        InputSource source = null;
        if (fEntityResolver != null) {
            source = fEntityResolver.resolveEntity("", location);
        }

        if (source == null) {
            location = expandSystemId(location, fCurrentSchemaURL);
            source = new InputSource(location);
        }
        // Make sure we don't redefine the same schema twice; it's allowed
        // but the specs encourage us to avoid it.
        // algorithm:  string is pubId+sysId or if both null then filename
        String pubId = "";
        String sysId = "";
        if (source.getPublicId () != null)
            pubId = source.getPublicId ();
        if (source.getSystemId () != null)
            sysId = source.getSystemId ();

        if(pubId.length() != 0 || sysId.length() != 0)
            location += pubId+sysId;

        // make sure we're not redefining ourselves!
        if(source.getSystemId().equals(fCurrentSchemaURL)) { // NPE if 
source.getSystemId() == null!

Possible solutions are to use the sysId variable which was previously set, or 
to require that the redefined schema's systemId be non-null and throw an 
exception with the appropriate message, or to require that either the current 
schema's systemId or the redefined schema's systemId be non-null and throw the 
appropriate exception.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to