Bug 1127329

Summary: [GSS] (6.4.0) Invalid boolean values are set to 'false' instead of null
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Kyle Lape <klape>
Component: XML FrameworksAssignee: Jason T. Greene <jason.greene>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Slavicek <pslavice>
Severity: unspecified Docs Contact: eap-docs <eap-docs>
Priority: unspecified    
Version: 6.3.0CC: jbliznak, kkhan
Target Milestone: DR1   
Target Release: EAP 6.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1127332 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1127326, 1127332    

Description Kyle Lape 2014-08-06 16:40:41 UTC
There are certain illegal values of an xs:boolean that return false when they should return null, namely values that start with t and f. In addition, if the string literals "t" and "f" are passed in, this will cause an unmarshalling error:

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 1
  at java.lang.AbstractStringBuilder.charAt(AbstractStringBuilder.java:203) [rt.jar:1.7.0_55]
  at java.lang.StringBuilder.charAt(StringBuilder.java:72) [rt.jar:1.7.0_55]
  at com.sun.xml.bind.DatatypeConverterImpl._parseBoolean(DatatypeConverterImpl.java:260)

Comment 1 Kyle Lape 2014-08-06 16:44:56 UTC
Upstream Jira: https://java.net/jira/browse/JAXB-1019

Comment 2 Kyle Lape 2014-08-18 05:20:51 UTC
Spec references:

------------------------------------------------------------------------
JAXB 2.2 spec, section B.3.8.1: Unparseable Data for Simple Types (p312)

  If simple type data cannot be parsed into a java datatype, then the
  value of the java datatype must not change the current set value. An
  access to the datatype must return the value as specified in Section
  B.3.8.2, “Missing element information item”. If the conversion of
  lexical representation into a value results in an exception, then the
  exception must be caught and a validation event reported. This is to
  ensure that such conversion errors do not terminate unmarshalling.

B.3.8.2 Missing element information item

  Property or field access must return the value specified in Section
  B.3.8.4, “Value for missing elements/attributes”

B.3.8.4 Value for missing elements/attributes

  If an attribute or an element is missing from an XML instance, then
  unmarshal will not change the current set value. An access to the
  property will return the set value or if unset, the uninitialized
  value. The uninitialized value of the property or field depends upon
  it's type. If the type is

  1. int-valueis0
  2. boolean - value is false
  3. a reference (must be mapped to a simple type) - value is null.
  ...

------------------------------------------------------------------------

XML Schema, part 2, secion 3.2.2: Primitive Datatypes: boolean
3.2.2.1 Lexical representation

  An instance of a datatype that is defined as ·boolean· can have the
  following legal literals {true, false, 1, 0}.

------------------------------------------------------------------------

So I interpret the above specs like this:

- The valid boolean values are {true, false, 1, 0}, excluding
  whitespace around the values

- If it's not one of those values, then:

  - If the type is a primitive "boolean", the value is false (default)
  - If the type is "java.lang.Boolean" (i.e. an object reference),
    then the value is null (default)

(Of course the invalid value should throw an exception if schema
validation is enabled; we are only talking about the default
unmarshalling value with schema validation disabled.)

Comment 3 Kabir Khan 2014-08-23 10:30:43 UTC
Should be fixed by jaxb upgrade to 2.2.5-redhat-9: https://bugzilla.redhat.com/show_bug.cgi?id=1127326

Comment 4 Jan Blizňák 2014-09-18 09:59:48 UTC
Verified on 6.4.0.DR1