We have two disconnected DataGraphs and when we add DataObjects from one
DataGraph into the other (with or without 'detach' being called) we are
observe ConcurrentModificationExceptions.  I have pasted a simple test
case below which adds a 'department' from one company into another.
This test case will error out with the above exception.  The company.xsd
is from the Tuscany M3 RC1 build.

 

Can someone explain this behavior and what should be the recommended
usage pattern?

 

  /**

   * @see junit.framework.TestCase#setUp()

   */

  @Override

  protected void setUp() throws Exception {

    XSDHelper.INSTANCE.define(ClassLoader

        .getSystemResourceAsStream("company.xsd"), null);

  }

 

  /**

   * Test list usage.

   */

  public void test01Concurrency() {

    DataGraph dataGraph_A = createCompanyDataGraph(1);

    DataGraph dataGraph_B = createCompanyDataGraph(1);

 

    List departments_A =
dataGraph_A.getRootObject().getList("departments");

    List departments_B =
dataGraph_B.getRootObject().getList("departments");

    for (Iterator iter = departments_A.iterator(); iter.hasNext();) {

      DataObject department_A = (DataObject) iter.next();

      department_A.detach(); // Does not matter if this call is made or
not

      departments_B.add(department_A);

    }

  }

 

  /**

   * Creates the company datagraph.

   * @param departmentsToCreate the number of departments to create.

   * @return the DataGraph.

   */

  private DataGraph createCompanyDataGraph(int departmentsToCreate) {

    DataGraph dataGraph = SDOUtil.createDataGraph();

    dataGraph.createRootObject("company.xsd", "CompanyType");

    for (int i = 0; i < departmentsToCreate; i++) {

      dataGraph.getRootObject().createDataObject("departments",
"company.xsd",

          "DepartmentType");

    }

    return dataGraph;

  }

 

Thanks,

Murtaza.

Reply via email to