[
https://issues.apache.org/jira/browse/XMLBEANS-300?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ben La Monica updated XMLBEANS-300:
-----------------------------------
Attachment: XMLBEANS-300.patch.txt
This has happened to me on a MP Solaris 8 box as well with XmlBeans 2.2.0.
Here is a patch that will synchronize this code. I agree with Gordon's
assessment, the NPE is happening when two threads try to get the component at
the same time when the component has not yet been resolved.
I chose to synchronize on a private member instead of the class, but the
maintainer will know better than I the correct way to synchronize this.
> Threading issue leads to NPE in SchemaComponent$Ref.getComponent
> ----------------------------------------------------------------
>
> Key: XMLBEANS-300
> URL: https://issues.apache.org/jira/browse/XMLBEANS-300
> Project: XMLBeans
> Issue Type: Bug
> Components: XmlObject
> Affects Versions: Version 2, Version 2.1, Version 2.2
> Reporter: Gordon Eastman
> Attachments: XMLBEANS-300.patch.txt
>
>
> We have seen this NPE during normal use of our application on a MP Solaris
> system using XmlBeans 2.0.0. I tested and confirmed it is still a problem in
> 2.2.0:
> java.lang.NullPointerException
> at
> org.apache.xmlbeans.SchemaComponent$Ref.getComponent(SchemaComponent.java:104)
> at org.apache.xmlbeans.SchemaType$Ref.get(SchemaType.java:872)
> at
> org.apache.xmlbeans.impl.schema.SchemaPropertyImpl.getType(SchemaPropertyImpl.java:92)
> at
> org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createElementType(SchemaTypeImpl.java:965)
> at
> org.apache.xmlbeans.impl.values.XmlObjectBase.create_element_user(XmlObjectBase.java:895)
> at org.apache.xmlbeans.impl.store.Xobj.getUser(Xobj.java:1592)
> at org.apache.xmlbeans.impl.store.Cur.getUser(Cur.java:2627)
> at org.apache.xmlbeans.impl.store.Cur.getObject(Cur.java:2620)
> at org.apache.xmlbeans.impl.store.Cursor._getObject(Cursor.java:983)
> at org.apache.xmlbeans.impl.store.Cursor.getObject(Cursor.java:2896)
> Here is how to reproduce with the debugger:
> - start two threads, each of which loads a different xml document with the
> same schema type
> - each thread will traverse its document, calling getObject at each element
> - break before traversal starts
> - insert breakpoint at SchemaComponent.java:104, and let both threads run to
> this point
> - resume one thread, and then the other
> - the second thread fails with the NPE
> Here is the code fragment from SchemaComponent $Ref:
> public final SchemaComponent getComponent()
> {
> if (_schemaComponent == null && _handle != null)
> {
> _schemaComponent = _schemaTypeSystem.resolveHandle(_handle);
> // this is line 104
> _schemaTypeSystem = null;
> }
> return _schemaComponent;
> }
> Both threads use the same Ref object, and there is no protection between use
> of _schemaTypeSystem on line 104 and setting it null on the next line
> I do not know enough about how thread protection of schema types is designed
> to know if a localized fix to synchronize the lazy instantiation is
> appropriate, or if synchronization at a higher level is appropriate.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]