Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-498

XmlValueOutOfRangeException on accessing xmlbean objects by multiple threads

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: Version 2.3, Version 2.6
    • Fix Version/s: None
    • Component/s: XmlObject
    • Environment:
      Linux Server

      Description

      We have two threads sharing the same xmlbeans object. Although they perform only read actions on it, we sometimes get exceptions like XmlValueOutOfRangeException, ArrayIndexOutOfBoundsException and NullPointerException. See below for example of an error stack.

      We found out, that all of the generated xmlbean object methods are thread safe, using "synchonize(monitor()") - that's fine. But some basic methods do not synchronize on monitor().

      e.g. we have a generated class EventDateImpl, which is derived from JavaGDateHolderEx. The method getCalendarValue() is implemented in XmlObjectBase, which forwards the call to JavaGDateHolderEx #calendarValue(), which accesses the check_date() method NOT secured by synchonize(monitor()).

      This leads to a race condition:

      -> XmlObjectBase#check_dated()
      -> XmlObjectBase#get_wscanon_text()
      -> Xobj#fetch_text (is the type store)
      -> Xobj#getValueAsString()
      -> getFirstChars()
      -> Xobj#getChars()
      -> Xobj#getCharsHelper()
      -> (over)writes the _locale._offSrc and _locale._cchSrc of the common shared Locale which are used by both threads reading on the xmlbeans object after a few lines in getValueAsString():
      scrub.scrub( src, _locale._offSrc, _locale._cchSrc );
      This leads to reading the wrong text and invalid data.

      Caused by: org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: Invalid date value: 26
      at org.apache.xmlbeans.impl.values.XmlObjectBase$ValueOutOfRangeValidationContext.invalid(XmlObjectBase.java:285) ~[xmlbeans-2.3.0.jar:na]
      at org.apache.xmlbeans.impl.values.JavaGDateHolderEx.lex(JavaGDateHolderEx.java:74) ~[xmlbeans-2.3.0.jar:na]
      at org.apache.xmlbeans.impl.values.JavaGDateHolderEx.set_text(JavaGDateHolderEx.java:56) ~[xmlbeans-2.3.0.jar:na]
      at org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1135) ~[xmlbeans-2.3.0.jar:na]
      at org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1274) ~[xmlbeans-2.3.0.jar:na]
      at org.apache.xmlbeans.impl.values.JavaGDateHolderEx.calendarValue(JavaGDateHolderEx.java:192) ~[xmlbeans-2.3.0.jar:na]
      at org.apache.xmlbeans.impl.values.XmlObjectBase.getCalendarValue(XmlObjectBase.java:1516) ~[xmlbeans-2.3.0.jar:na]

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gerhard Gerhard
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: