Gerhard created XMLBEANS-498:
--------------------------------
Summary: XmlValueOutOfRangeException on accessing xmlbean objects
by multiple threads
Key: XMLBEANS-498
URL: https://issues.apache.org/jira/browse/XMLBEANS-498
Project: XMLBeans
Issue Type: Bug
Components: XmlObject
Affects Versions: Version 2.3, Version 2.6
Environment: Linux Server
Reporter: Gerhard
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]
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]