Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

"Zero length BigInteger" error when unmarshaling #1193

Open
LanceAndersen opened this issue Apr 27, 2018 · 0 comments
Open

"Zero length BigInteger" error when unmarshaling #1193

LanceAndersen opened this issue Apr 27, 2018 · 0 comments

Comments

@LanceAndersen
Copy link

Previously tracked via: https://bugs.openjdk.java.net/browse/JDK-8074027

Let's consider following XSD and XML document:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 

<xsd:element name="root"> 
   <xsd:complexType> 
      <xsd:sequence> 
         <xsd:element name="str" type="xsd:string" fixed="abc"/> 
         <xsd:element name="number" type="xsd:integer" fixed="123"/> 
         <xsd:element name="bool" type="xsd:boolean" fixed="true"/> 
      </xsd:sequence> 
   </xsd:complexType> 
</xsd:element> 
</xsd:schema> 


<root> 
   <str/> 
   <number/> 
   <bool/> 
</root> 

when this XML document is unmarshlled following error occurs:

javax.xml.bind.UnmarshalException: Zero length BigInteger 
 - with linked exception: 
[java.lang.NumberFormatException: Zero length BigInteger] 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:728) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:755) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:751) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.handleParseConversionException(Loader.java:260) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:54) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:574) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.text(ValidatingUnmarshaller.java:115) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.processText(SAXConnector.java:198) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:161) 
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:608) 
        at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:183) 
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:355) 
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2790) 
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) 
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116) 
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) 
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:876) 
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:805) 
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:140) 
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1212) 
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:243) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:214) 
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157) 
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:162) 
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:171) 
        at Test7.test(Test7.java:214) 
        at Test7.main(Test7.java:109) 
Caused by: java.lang.NumberFormatException: Zero length BigInteger 
        at java.math.BigInteger.<init>(BigInteger.java:397) 
        at java.math.BigInteger.<init>(BigInteger.java:583) 
        at com.sun.xml.internal.bind.DatatypeConverterImpl._parseInteger(DatatypeConverterImpl.java:76) 
        at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$21.parse(RuntimeBuiltinLeafInfoImpl.java:777) 
        at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$21.parse(RuntimeBuiltinLeafInfoImpl.java:775) 
        at com.sun.xml.internal.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:230) 
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:50) 
        ... 23 more 

But it seems that this documents should be processed correctly as per W3C spec [1]:

If fixed is specified, then the element's content must either be empty, in which case fixed behaves as default, or its value must match the supplied constraint value. 

The minimized test case is attached, actually there are two XML documents causing this error.

In order to reproduce this error:

  1. Extract attached archive to some directory on Windows platform, say A.
  2. Change current directory to directory A.
  3. Run test7-run2.bat.

The generated classes along with some other stuff generated from minimized testcase are attached as well.

[1] http://www.w3.org/TR/xmlschema-1/#Element_Declaration_details

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant