You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by paul_se <pa...@anz.com> on 2008/09/02 03:07:27 UTC

Deep copy not as I expected...

Hi,

I've found that when doing a deep copy, the new copy still uses the same
Locale as the original. When the original changes and its version (held in
the Locale) is updated (i.e. when doing another deep copy, why this changes
it I'm not sure), when I try to do an xpath evaluation on the copy it gives
me a ConcurrentModificationException (as the copy's version number is copied
into an xpath engine class for xpath evaluation and then compared to its
Locale version number during traversal of the xpath results, which has been
incremented).

Error is thrown from here…

Caused by: java.util.ConcurrentModificationException: Document changed
during select
	at org.apache.xmlbeans.impl.store.Path$XbeanPathEngine.next(Path.java:462)
	at org.apache.xmlbeans.impl.store.Cursor._toSelection(Cursor.java:931)
	at
org.apache.xmlbeans.impl.store.Cursor._getSelectionCount(Cursor.java:946)
	at
org.apache.xmlbeans.impl.store.Cursor.getSelectionCount(Cursor.java:2706)
	at
org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:468)
	at
org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:446)
	…

I've seen that the XmlOption Locale.COPY_USE_NEW_LOCALE is mentioned in the
class org.apache.xmlbeans.impl.store.Locale but there is no way of setting
it on XmlOptions. Any ideas why it is kept internal? Would like to try
setting it to see if this gets round my problem?

Hope that makes some sense - any ideas appreciated or I'll have to raise a
bug with XmlBeans.

Thanks.

-- 
View this message in context: http://www.nabble.com/Deep-copy-not-as-I-expected...-tp19262771p19262771.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Deep copy not as I expected...

Posted by paul_se <pa...@anz.com>.
Had to get around the issue to basically doing my own deep copy so the new
copy doesn't have a version number linked to the original:

	public static XmlObject deepCopy(XmlObject orig) {
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		
		try {
			orig.save(bos);
			
			ByteArrayInputStream is = new ByteArrayInputStream(bos.toByteArray());
	
			if(orig.schemaType().equals(TradingSession.type)) {
				return TradingSession.Factory.parse(is);
			}

                         .........


paul_se wrote:
> 
> Hi,
> 
> I've found that when doing a deep copy, the new copy still uses the same
> Locale as the original. When the original changes and its version (held in
> the Locale) is updated (i.e. when doing another deep copy, why this
> changes it I'm not sure), when I try to do an xpath evaluation on the copy
> it gives me a ConcurrentModificationException (as the copy's version
> number is copied into an xpath engine class for xpath evaluation and then
> compared to its Locale version number during traversal of the xpath
> results, which has been incremented).
> 
> Error is thrown from here…
> 
> Caused by: java.util.ConcurrentModificationException: Document changed
> during select
> 	at
> org.apache.xmlbeans.impl.store.Path$XbeanPathEngine.next(Path.java:462)
> 	at org.apache.xmlbeans.impl.store.Cursor._toSelection(Cursor.java:931)
> 	at
> org.apache.xmlbeans.impl.store.Cursor._getSelectionCount(Cursor.java:946)
> 	at
> org.apache.xmlbeans.impl.store.Cursor.getSelectionCount(Cursor.java:2706)
> 	at
> org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:468)
> 	at
> org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:446)
> 	…
> 
> I've seen that the XmlOption Locale.COPY_USE_NEW_LOCALE is mentioned in
> the class org.apache.xmlbeans.impl.store.Locale but there is no way of
> setting it on XmlOptions. Any ideas why it is kept internal? Would like to
> try setting it to see if this gets round my problem?
> 
> Hope that makes some sense - any ideas appreciated or I'll have to raise a
> bug with XmlBeans.
> 
> Thanks.
> 
> 

-- 
View this message in context: http://www.nabble.com/Deep-copy-not-as-I-expected...-tp19262771p19280847.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org