Stefan Guggisberg wrote:
 According to Julian, it does not throw an exception for him. Which is a
bug.

it does throw an exception in my case.

See attached test case -- which passes over here.

Maybe it depends on config/pm settings/whatever?

BR, Julian
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jackrabbit.benchmark;

import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;

import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;

import org.apache.jackrabbit.test.AbstractJCRTest;

public class ConcurrentUpdateTest extends AbstractJCRTest {

  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);
    Node c1 = n1.getNode("jcr:content");
    Property d1 = c1.getProperty("jcr:data");
    assertEquals(testcontent, d1.getString());
    
    Node n2 = (Node)session2.getItem(testnodepath);
    Node c2 = n2.getNode("jcr:content");
    Property d2 = c2.getProperty("jcr:data");
    assertEquals(testcontent, d2.getString());
    
    // modify through session1
    
    c1.setProperty("jcr:data", testcontent + ", as modified by session 1");

    // modify persisted property through session 2
    c2.setProperty("jcr:data", testcontent + ", as modified by session 2");
    n2.save();

    // now try to save session 1... should fail
    n1.save(); 
  }

}

Reply via email to