[
https://issues.apache.org/jira/browse/XERCESJ-1488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12971204#action_12971204
]
Mukul Gandhi commented on XERCESJ-1488:
---------------------------------------
Hi Michael,
I've just now renamed variable fisAtomicValueValid to
fisAtomicValueValidForSTVarietyUnion (and have committed this change), which
reflects the purpose of this variable better. The variable fisAtomicValueValid
(now fisAtomicValueValidForSTVarietyUnion) is used to track validity of atomic
value, when validated by a schema simpleType having variety union when that
simpleType also has assertion facet(s).
In the class XMLAssertPsychopathImpl.java assertions are evaluated only if
value of boolean variable fisAtomicValueValidForSTVarietyUnion is true (whose
value is set from XMLSchemaValidator). For simpleType -> union cases if an
atomic value is determined to be invalid in XMLSchemaValidator, then there is
no need to evaluate assertions in XMLAssertPsychopathImpl. I think this is true
by the nature of simpleType -> union type's having assertions.
The logic in question reflects this particular XML schema language design.
I'm open to having any discussions to make this part of logic better (though I
don't forsee any need of such thing now).
Regards,
Mukul
> NullPointerException caused by XMLSchemaValidator.addDefaultAttributes
> ----------------------------------------------------------------------
>
> Key: XERCESJ-1488
> URL: https://issues.apache.org/jira/browse/XERCESJ-1488
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.1 Structures
> Affects Versions: 2.11.0
> Environment: Java version: 1.6.0_23
> Java home: C:\Program Files\Java\jdk1.6.0_23\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows vista" version: "6.0" arch: "amd64" Family: "windows"
> Reporter: Gary Gregory
> Assignee: Khaled Noaman
> Priority: Blocker
>
> The following is a regression from 2.10 because our unit tests run OK with
> 2.10 and blow up with 2.11.
> NullPointerException caused by XMLSchemaValidator.addDefaultAttributes
> Note that the second argument is null in the call:
> {noformat}
> if (XSTypeHelper.isAtomicValueValidForAnUnion(attDV.getMemberTypes(),
> null, defaultValue)) {
> {noformat}
> at
> XMLSchemaValidator.addDefaultAttributes(QName, XMLAttributes,
> XSAttributeGroupDecl) line: 3385
> Which means that at this point in the call chain:
> {noformat}
> Thread [main] (Suspended (breakpoint at line 2255 in XSSimpleTypeDecl))
> XSSimpleTypeDecl.normalize(Object, short) line: 2255
> XSSimpleTypeDecl.getActualValue(Object, ValidationContext,
> ValidatedInfo, boolean) line: 2053
> XSSimpleTypeDecl.validate(String, ValidationContext, ValidatedInfo)
> line: 1742
> XSTypeHelper.isValueValidForASimpleType(String, XSSimpleType) line: 135
> XSTypeHelper.isAtomicValueValidForAnUnion(XSObjectList, String,
> ValidatedInfo) line: 108
> XMLSchemaValidator.addDefaultAttributes(QName, XMLAttributes,
> XSAttributeGroupDecl) line: 3385
> XMLSchemaValidator.handleStartElement(QName, XMLAttributes,
> Augmentations) line: 2375
> XMLSchemaValidator.startElement(QName, XMLAttributes, Augmentations)
> line: 815
> XMLNSDocumentScannerImpl.scanStartElement() line: 283
> XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook()
> line: 733
>
> XMLNSDocumentScannerImpl$NSContentDispatcher(XMLDocumentFragmentScannerImpl$FragmentContentDispatcher).dispatch(boolean)
> line: 1754
>
> XMLNSDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean)
> line: 324
> IntegratedParserConfiguration(DTDConfiguration).parse(boolean) line:
> 515
> IntegratedParserConfiguration(DTDConfiguration).parse(XMLInputSource)
> line: 571
> DOMParser(XMLParser).parse(XMLInputSource) line: 108
> DOMParser.parse(InputSource) line: 230
> DocumentBuilderImpl.parse(InputSource) line: 298
> XmlValidator.validate(InputSource) line: 279
> XmlValidator.validate(URL) line: 317
> XmlValidator.validate(String) line: 300
> XmlValidatorTestCase.validateXmlSchema1_0_2(String) line: 187
> XmlValidatorTestCase.testSimpleXsd_XmlSchema1_0_2() line: 126
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
> available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
> Method.invoke(Object, Object...) line: 597
> FrameworkMethod$1.runReflectiveCall() line: 44
> FrameworkMethod$1(ReflectiveCallable).run() line: 15
> FrameworkMethod.invokeExplosively(Object, Object...) line: 41
> InvokeMethod.evaluate() line: 20
> BlockJUnit4ClassRunner.runNotIgnored(FrameworkMethod, EachTestNotifier)
> line: 79
> BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) line: 71
> BlockJUnit4ClassRunner.runChild(Object, RunNotifier) line: 49
> ParentRunner$3.run() line: 193
> ParentRunner$1.schedule(Runnable) line: 52
> BlockJUnit4ClassRunner(ParentRunner<T>).runChildren(RunNotifier) line:
> 191
> ParentRunner<T>.access$000(ParentRunner, RunNotifier) line: 42
> ParentRunner$2.evaluate() line: 184
> BlockJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: 236
> JUnit4TestMethodReference(JUnit4TestReference).run(TestExecution) line:
> 49
> TestExecution.run(ITestReference[]) line: 38
> RemoteTestRunner.runTests(String[], String, TestExecution) line: 467
> RemoteTestRunner.runTests(TestExecution) line: 683
> RemoteTestRunner.run() line: 390
> RemoteTestRunner.main(String[]) line: 197
> {noformat}
>
> The "return null;" runs at:
> XSSimpleTypeDecl.normalize(Object, short) line: 2255
> {noformat}
> if (content == null)
> return null;
> {noformat}
>
> Which then causes:
> {noformat}
> java.lang.NullPointerException
> at java.util.StringTokenizer.<init>(StringTokenizer.java:182)
> at java.util.StringTokenizer.<init>(StringTokenizer.java:204)
> at
> org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.getActualValue(XSSimpleTypeDecl.java:2105)
> at
> org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.validate(XSSimpleTypeDecl.java:1742)
> at
> org.apache.xerces.impl.xs.util.XSTypeHelper.isValueValidForASimpleType(XSTypeHelper.java:135)
> at
> org.apache.xerces.impl.xs.util.XSTypeHelper.isAtomicValueValidForAnUnion(XSTypeHelper.java:108)
> at
> org.apache.xerces.impl.xs.XMLSchemaValidator.addDefaultAttributes(XMLSchemaValidator.java:3385)
> at
> org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2375)
> at
> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:815)
> at
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:283)
> at
> org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:733)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1754)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
> at
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:515)
> at
> org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:571)
> at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
> at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:230)
> at
> org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:298)
> at
> com.seagullsw.toolbox.xml.XmlValidator.validate(XmlValidator.java:279)
> at
> com.seagullsw.toolbox.xml.XmlValidator.validate(XmlValidator.java:317)
> at
> com.seagullsw.toolbox.xml.XmlValidator.validate(XmlValidator.java:300)
> at
> com.seagullsw.toolbox.xml.XmlValidatorTestCase.validateXmlSchema1_0_2(XmlValidatorTestCase.java:187)
> at
> com.seagullsw.toolbox.xml.XmlValidatorTestCase.testSimpleXsd_XmlSchema1_0_2(XmlValidatorTestCase.java:126)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> {noformat}
> because the null value is passed all the way down the call chain until it
> causes the implosion.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]