Adding files from different threads in same Folder to SVN fails

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Adding files from different threads in same Folder to SVN fails

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.openDir(parentPath, -1);
    System.out.println(String.format("Opened dir %s for commit of file %s", parentPath, svnfilePath ));
        editor.addFile(svnfilePath, null, -1);
        System.out.println(String.format("Added file %s", svnfilePath ));
        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(); //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 (
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(

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.