[jboss-jira] [JBoss JIRA] (DROOLS-1622) NPE when compiling DMN file from test DMNRuntimeTest.testNoPrefix on IBM JDK

Matteo Mortari (JIRA) issues at jboss.org
Wed Jun 21 05:46:00 EDT 2017


    [ https://issues.jboss.org/browse/DROOLS-1622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13424542#comment-13424542 ] 

Matteo Mortari edited comment on DROOLS-1622 at 6/21/17 5:45 AM:
-----------------------------------------------------------------

Some investigation results.

This is about {{com.thoughtworks.xstream.io.xml.StaxReader}}
method {{public String getAttribute(final String name)}}.

When called with openjdk, this calls {{com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl}}

which respects the javadoc specs, in the case the "namespace" parameter is passed as null:

{code:java}
String javax.xml.stream.XMLStreamReader.getAttributeValue(String namespaceURI, String localName)

Returns the normalized attribute value of the attribute with the namespace and localName If the namespaceURI is null the namespace is not checked for equality

Parameters:
namespaceURI the namespace of the attribute
localName the local name of the attribute, cannot be null
{code}

while on IBM JDK it calls {{com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl$XMLStreamReaderProxy}} which in turns calls

{code:java}
String com.ibm.xml.xlxp.api.stax.XMLStreamReaderImpl.getAttributeValue(String s, String s2)
{code}

which in turn calling

{code:java}
/*      */     public XMLString getAttributeValue(final int n, final int n2) {
/*      */ 
/* 1817 */         if (((SimpleScannerHelper)this).fIsNamespaceAware) {
/* 1818 */             for (int i = 0; i < ((SimpleScannerHelper)this).fAttributeCount; ++i) {
/* 1819 */                 final com.ibm.xml.xlxp.scan.util.QName attributeName = this.attributeName(i);
/* 1820 */                 if (n2 == attributeName.localHandle && n == attributeName.nsHandle) {
/* 1821 */                     return this.normalizedAttributeValue(i);
/*      */                 }
/*      */             }
/*      */         }
/*      */         else {
/* 1826 */             for (int j = 0; j < ((SimpleScannerHelper)this).fAttributeCount; ++j) {
/*      */ 
/* 1828 */                 if (n2 == this.attributeName(j).handle) {
/* 1829 */                     return this.normalizedAttributeValue(j);
/*      */                 }
/*      */             }
/*      */         }
/* 1833 */         return null;
/*      */     }
{code}

and we can see line 1820 it *forcibly* check the namespace for the attribute corresponds, in this case null = 0, so it check the attribute namespace is null.

This is not compliant with the Java JDK javadoc specs.


was (Author: tari_manga):
Some investigation results.

This is about {{com.thoughtworks.xstream.io.xml.StaxReader}}
method {{public String getAttribute(final String name)}}.

When called with openjdk, this calls {{com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl}}

which respects the javadoc specs:

{code:java}
String javax.xml.stream.XMLStreamReader.getAttributeValue(String namespaceURI, String localName)

Returns the normalized attribute value of the attribute with the namespace and localName If the namespaceURI is null the namespace is not checked for equality

Parameters:
namespaceURI the namespace of the attribute
localName the local name of the attribute, cannot be null
{code}

while on IBM JDK it calls {{com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl$XMLStreamReaderProxy}} which in turns calls

{code:java}
String com.ibm.xml.xlxp.api.stax.XMLStreamReaderImpl.getAttributeValue(String s, String s2)
{code}

which in turn calling

{code:java}
/*      */     public XMLString getAttributeValue(final int n, final int n2) {
/*      */ 
/* 1817 */         if (((SimpleScannerHelper)this).fIsNamespaceAware) {
/* 1818 */             for (int i = 0; i < ((SimpleScannerHelper)this).fAttributeCount; ++i) {
/* 1819 */                 final com.ibm.xml.xlxp.scan.util.QName attributeName = this.attributeName(i);
/* 1820 */                 if (n2 == attributeName.localHandle && n == attributeName.nsHandle) {
/* 1821 */                     return this.normalizedAttributeValue(i);
/*      */                 }
/*      */             }
/*      */         }
/*      */         else {
/* 1826 */             for (int j = 0; j < ((SimpleScannerHelper)this).fAttributeCount; ++j) {
/*      */ 
/* 1828 */                 if (n2 == this.attributeName(j).handle) {
/* 1829 */                     return this.normalizedAttributeValue(j);
/*      */                 }
/*      */             }
/*      */         }
/* 1833 */         return null;
/*      */     }
{code}

and we can see line 1820 it *forcibly* check the namespace for the attribute corresponds, in this case null = 0, so it check the attribute namespace is null.

This is not compliant with the Java JDK javadoc specs.

> NPE when compiling DMN file from test DMNRuntimeTest.testNoPrefix on IBM JDK
> ----------------------------------------------------------------------------
>
>                 Key: DROOLS-1622
>                 URL: https://issues.jboss.org/browse/DROOLS-1622
>             Project: Drools
>          Issue Type: Bug
>          Components: dmn engine
>    Affects Versions: 7.0.0.Final
>            Reporter: Tibor Zimányi
>            Assignee: Matteo Mortari
>              Labels: reported-by-qe
>             Fix For: 7.1.0.Final
>
>
> When running test [1] on IBM JDK, the test fails with this output [2].
> [1] https://github.com/kiegroup/drools/blob/32822e243a237cf26f26830a895035b97ba5a643/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNRuntimeTest.java#L845
> [2] https://gist.github.com/baldimir/969bd8f72665ff0e4244350abaed1ef4



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)



More information about the jboss-jira mailing list