You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Brian McDonald (JIRA)" <ji...@apache.org> on 2010/05/17 19:37:52 UTC

[jira] Updated: (WSCOMMONS-539) Infinite loop in XmlSchemaSerializer. setupNamespaces

     [ https://issues.apache.org/jira/browse/WSCOMMONS-539?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brian McDonald updated WSCOMMONS-539:
-------------------------------------

    Attachment: stockquote2.wsdl.xml

I'm attaching a wsdl that can show you the issue (Ironically it's from the spec - http://www.w3.org/TR/wsdl)

> Infinite loop in XmlSchemaSerializer. setupNamespaces
> -----------------------------------------------------
>
>                 Key: WSCOMMONS-539
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-539
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: XmlSchema
>    Affects Versions: XmlSchema 1.4.6
>            Reporter: Brian McDonald
>            Priority: Critical
>         Attachments: stockquote2.wsdl.xml
>
>
> This block of code can cause an infinite loop:
>         if (xsdPrefix == null) {
> 	            //find a prefix to use
> 	            xsdPrefix = "";
> 	            if (ctx != null && ctx.getNamespaceURI(xsdPrefix) != null) {
>  	                xsdPrefix = "xsd";
> 	             }
> 	            int count = 0;
>  	            while (ctx != null && ctx.getNamespaceURI(xsdPrefix) != null) {
>  	                xsdPrefix = "xsd" + ++count;	 	 	            
>                     }
> 	        }
> The crux of the problem is that getNamespaceURI will never return null. If the namespace uri isn't found it returns XMLConstants.NULL_NS_URI.
> This code should help:
>         if(xsdPrefix == null) {
>             //find a prefix to use
>             xsdPrefix = XMLConstants.DEFAULT_NS_PREFIX;
>             // Note: NULL_NS_URI is *not* the same as the null reference!
>             if (ctx != null && !XMLConstants.NULL_NS_URI.equals(ctx.getNamespaceURI(xsdPrefix))) {
>                 xsdPrefix = "xsd";
>             }
>             int count = 0;
>             while (ctx != null && !XMLConstants.NULL_NS_URI.equals(ctx.getNamespaceURI(xsdPrefix))) {
>                 xsdPrefix = "xsd" + ++count;
>             }
>             schemaObj.schema_ns_prefix = xsdPrefix;
>         }        

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.