I have assertions enabled for v.2.2.0 of XmlBeans under JDK 1.5_10.
While trying to validate my bean, I get an AssertionError at the
following location:
at
org.apache.xmlbeans.impl.values.XmlObjectBase.build_text(XmlObjectBase.j
ava:837)
at
org.apache.xmlbeans.impl.store.Xobj.ensureOccupancy(Xobj.java:1694)
at org.apache.xmlbeans.impl.store.Cur.next(Cur.java:1444)
at
org.apache.xmlbeans.impl.store.Validate.process(Validate.java:74)
at
org.apache.xmlbeans.impl.store.Validate.<init>(Validate.java:39)
at org.apache.xmlbeans.impl.store.Xobj.validate(Xobj.java:1860)
at
org.apache.xmlbeans.impl.values.XmlObjectBase.validate(XmlObjectBase.jav
a:343)
The line of code is
assert((_flags & FLAG_VALUE_DATED) == 0);
In other words, after a set() call, the value is in an invalid state.
What is happening is that I'm first setting various values in the bean
and then validating it. It appears that, if I set a value that had
previously been 'nil', then the above flag gets set on the element:
XmlBase64BinaryImpl(XmlObjectBase).invalidate_nilvalue() line:
792
Xobj$ElementXobj(Xobj).invalidateNil() line: 1385
Xobj$AttrXobj(Xobj).invalidateSpecialAttr(Xobj) line: 915
Cur.moveNode(Xobj, Cur) line: 1922
Cur.moveNode(Cur) line: 1841
Xobj$ElementXobj(Xobj).removeAttr(QName) line: 520
Xobj$ElementXobj(Xobj).invalidate_nil() line: 2038
XmlBase64BinaryImpl(XmlObjectBase).set_commit() line: 1313
XmlBase64BinaryImpl(XmlObjectBase).set(byte[]) line: 1617
XmlBase64BinaryImpl(XmlObjectBase).setByteArrayValue(byte[])
line: 1553
SymbolImpl.setSymbolData(byte[]) line: 466
The set occurs, but, after the set, the 'nil' attribute is cleared,
which calls the following code:
public final void invalidate_nilvalue()
{
assert((_flags & FLAG_STORE) != 0);
_flags |= FLAG_VALUE_DATED | FLAG_NIL_DATED;
}
This code very clearly sets the FLAG_VALUE_DATA flag, which leaves the
entire element in an invalid state.
Is this how everything should work? Is the assert incorrect? Is there
something I should be doing to the bean after I set the values? How
should I approach dealing with this? I'm running into this quite a bit,
so I would appreciate any help.
Thank you,
jvc