You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by "sit (JIRA)" <ji...@apache.org> on 2015/11/23 10:17:11 UTC

[jira] [Comment Edited] (SANTUARIO-433) IBM JVM does not support null for NameSpace prefix

    [ https://issues.apache.org/jira/browse/SANTUARIO-433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15021792#comment-15021792 ] 

sit edited comment on SANTUARIO-433 at 11/23/15 9:16 AM:
---------------------------------------------------------

* Every thing is working fine up to now. All xmlsec JUnit tests run without problem.  We have also tested it for Wildfly 8.2, JBoss EAP 6 & Websphere 8.5.5.5.x. We will have code freezed with this change.

* As a matter of fact, I am using a modified version of XMLReaderToWriter from Colm O hEigeartaigh's testCases-master projet.
...
    if (StringUtils.isBlank(prefix))
                {
                    writer.writeDefaultNamespace(nameSpace);
                }
                else
                {
                    writer.writeNamespace(prefix, nameSpace);
                }
    }
...
As in XMLSecurityStreamWriter.writeDefaultNameSpace(nameSpace), we don't pass in prefix parameter (there is none), the instruction "if (this.openStartElement.getElementPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) " will produce a NullPointerException if the getElementPrefix() is null.

Quoted from the JDK interface XMLStreamWriter.writeNameSpace(prefix, nameSpace), comments, 

   * If the prefix argument to this method is the empty string,
   * "xmlns", or null this method will delegate to writeDefaultNamespace

So prefix in one of the above three cases will be defaulted to default namespace prefix. So it seems that null is a possible returned valued from a XML parser.
I think it is a question of XML parser returning prefix as null in some cases.
So my precaution is to set prefix to "" in case of null. It does no harm to any existing codes. All xmlsec JUnit test cases run fine.

P.S.
* This only happens on WebSphere 8.5.5.5.x. 
* I also send you the XMLReaderToWriter.java via email for info.





was (Author: csit):
* Every thing is working fine up to now. All xmlsec JUnit tests run without problem.  We have also tested it for Wildfly 8.2, JBoss EAP 6 & Websphere 8.5.5.5.x. We will have code freezed with this change.

* As a matter of fact, I am using a modified version of XMLReaderToWriter from Colm O hEigeartaigh's testCases-master projet.
...
    if (StringUtils.isBlank(prefix))
                {
                    writer.writeDefaultNamespace(nameSpace);
                }
                else
                {
                    writer.writeNamespace(prefix, nameSpace);
                }
    }
...
As in XMLSecurityStreamWriter.writeDefaultNameSpace(nameSpace), we don't pass in prefix parameter (there is none), the instruction "if (this.openStartElement.getElementPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) " will produce a NullPointerException if the getElementPrefix() is null.

Quoted from the JDK interface XMLStreamWriter.writeNameSpace(prefix, nameSpace), comments, 

   * If the prefix argument to this method is the empty string,
   * "xmlns", or null this method will delegate to writeDefaultNamespace

So prefix in one of the above three cases will be defaulted to default namespace prefix. So it seems that null is a possible returned valued from a XML parser.
I think it is a question of XML parser returning prefix as null in some cases.
So my precaution is to set prefix to "" in case of null. It does no harm to any existing codes. All xmlsec JUnit test cases run fine.


> IBM JVM does not support null for NameSpace prefix
> --------------------------------------------------
>
>                 Key: SANTUARIO-433
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-433
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 2.0.5
>         Environment: IBM WebSphere 8.5.5
>            Reporter: sit
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When running under WAS 8.5.5.5 under Windows 7, 
> 1. XMLSecurityStreamWriter.writeDefaultNamespace() fails with null pointerException at line 296: this.openStartElement.getElementPrefix() return null
> 2. XMLSecurityStreamWriter$Element.getQName (XMLSecurityStreamWriter.java:538) Caused by: java.lang.IllegalArgumentException: prefix cannot be "null" when creating a QName
> 	at javax.xml.namespace.QName.<init>(Unknown Source)
> 	at org.apache.xml.security.stax.impl.XMLSecurityStreamWriter $Element.getQName(XMLSecurityStreamWriter.java:538)
> Both are due to the fact that IBM JVM 1.6 deos not allow NS prefix = null



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)