Hi,

I was expecting that Jackrabbit is detecting concurrent modifications to a node, and reject them with an InvalidItemStateException.

However, this test:

public void testoverlappingUpdate() throws RepositoryException, UnsupportedEncodingException {

    String testcontent = "base version";

    Session session1 = testRootNode.getSession();
    Session session2 = super.superuser;

    // create the test node

    Node testnode = testRootNode.addNode("testconcurrent", "nt:file");
    String testnodepath = testnode.getPath();
    Node testnodec = testnode.addNode("jcr:content", "nt:resource");
testnodec.setProperty("jcr:data", new ByteArrayInputStream(testcontent.getBytes("UTF-8")));
    testnodec.setProperty("jcr:lastModified", Calendar.getInstance());
    testnodec.setProperty("jcr:mimeType", "text/plain");
    session1.save();
    session1.refresh(false);

    // retrieve it through both sessions

    Node n1 = (Node)session1.getItem(testnodepath);
assertEquals(testcontent, n1.getProperty("jcr:content/jcr:data").getString());

    Node n2 = (Node)session2.getItem(testnodepath);
assertEquals(testcontent, n2.getProperty("jcr:content/jcr:data").getString());

    // modify through session1

n1.getNode("jcr:content").setProperty("jcr:data", testcontent + ", as modified by session 1");
    n1.save();

    // modify through session2

n2.getNode("jcr:content").setProperty("jcr:data", testcontent + ", as modified by session 2");
    n2.save();
  }

Is this a regression?

BR, Julian

(I'm aware that detecting this is optional, but my understanding was that the RI was doing this at some point of time...)

Reply via email to