Bug 1127329 - [GSS] (6.4.0) Invalid boolean values are set to 'false' instead of null
Summary: [GSS] (6.4.0) Invalid boolean values are set to 'false' instead of null
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: XML Frameworks
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: DR1
: EAP 6.4.0
Assignee: Jason T. Greene
QA Contact: Pavel Slavicek
eap-docs
URL:
Whiteboard:
Depends On:
Blocks: 1127326 1127332
TreeView+ depends on / blocked
 
Reported: 2014-08-06 16:40 UTC by Kyle Lape
Modified: 2019-08-19 12:42 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1127332 (view as bug list)
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.