Hi Ron,
Unfortunately, XMLHelper.save() has the side-effect of temporarily
removing the DataObject from its container (i.e., the quotes list in your
case). It puts it back before returning from save(), but unfortunately
iterators don't allow any kind of manipulation to happen.
Rather than copy, a sollution with better performance would be to use a
counter instead of an iterator, something like this:
for (int index = 0; index < quotes.size(); ++index;) {
DataObject quote = (DataObject)quotes.get(index);
xmlh.save(quote, null, "quotes");
}
Frank.
Ron Gavlin <[EMAIL PROTECTED]>
10/29/2007 02:28 PM
Please respond to
[email protected]
To
tuscany-user tuscany-user <[email protected]>
cc
Subject
XMLHelper.save() expected behavior
Greetings,
I added the following simple method to XMLHelperTestCase. When I invoke
this new test method, a ConcurrentModificationException is thrown (see the
stack trace below). Is this the expected behavior? I can avoid the problem
by making a copy of the quote DataObject before I save it. However, it is
not clear to me why this is necessary.
- Ron
public void testSaveDataObjectListEntries() throws IOException
{
XMLDocument doc =
xmlh.load(getClass().getResource("/simpleWithChangeSummary.xml").openStream());
List quotes = doc.getRootObject().getList("quotes");
for (Iterator iterator = quotes.iterator(); iterator.hasNext();) {
DataObject quote = (DataObject)iterator.next();
xmlh.save(quote, null, "quotes");
}
}
java.util.ConcurrentModificationException
at
org.eclipse.emf.common.util.BasicEList$EIterator.checkModCount(BasicEList.java:1327)
at
org.eclipse.emf.common.util.BasicEList$EIterator.next(BasicEList.java:1275)
at
org.apache.tuscany.sdo.test.XMLHelperTestCase.testSaveDataObjectListEntries(XMLHelperTestCase.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]