Adding files from different threads in same Folder to SVN fails

Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Adding files from different threads in same Folder to SVN fails

vivek_acharya21
This post has NOT been accepted by the mailing list yet.
We are trying to add different files from different threads in the same Folder to SVN using SVNKit. We are using Low level SVNKit APIs (SVNRepository and ISVNEditor)

Code is like following and it is being called from multiple threads concurrently,

ISVNEditor editor = svnRepository.getCommitEditor("example modification", null, true, null);
    editor.openRoot(-1);
    editor.openDir(parentPath, -1);
    System.out.println(String.format("Opened dir %s for commit of file %s", parentPath, svnfilePath ));
    if(!isFilePresent)
    {
        editor.addFile(svnfilePath, null, -1);
        System.out.println(String.format("Added file %s", svnfilePath ));
    }
    else
    {
        editor.openFile(svnfilePath, -1);
        System.out.println(String.format("Opened file %s", svnfilePath ));
    }
    editor.applyTextDelta(svnfilePath, null);
    final SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
    InputStream             inputStream    = new FileInputStream(sourcePath.toFile());

    final String            checksum       = deltaGenerator.sendDelta(svnfilePath, inputStream, editor, true);
    editor.closeFile(svnfilePath, checksum);
    editor.closeDir();
    editor.closeDir(); //close the root
    SVNCommitInfo commitInfo = editor.closeEdit();

We are getting following exception,

org.tmatesoft.svn.core.SVNException: svn: E160024: File or directory 'test' is out of date; try updating
svn: E160024: version resource newer than txn (restart the commit)
svn: E175002: CHECKOUT of '/svn/temp/!svn/ver/6435/test': 409 Conflict (http://XXXXXXXXXX.com:444)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:112)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:96)
at org.tmatesoft.svn.core.internal.io.dav.DAVCommitEditor.checkoutResource(DAVCommitEditor.java:631)
at org.tmatesoft.svn.core.internal.io.dav.DAVCommitEditor.addFile(DAVCommitEditor.java:304)

So how can we add multiple files concurrently using SVNKit. We want to avoid synchronization for Add as many users can simultaneously add new files.



Loading...