Hello,
SVN*Client API methods are not thread safe. You should use separate
instance of SVNClientManager per thread. You may use ThreadLocal
class:
private static ThreadLocal<SVNClientManager> manager = new
ThreadLocal<SVNClientManager>();
public void method() {
if (manager.get() == null) {
manager.set(SVNClientManager.newInstance());
}
SVNClientManager m = manager.get();
m.getWCClient().doGetFileContent(...);
...
}
Alexander Kitaev,
TMate Software,
http://subgit.com/ - Svn to Git Migration!
http://svnkit.com/ - Java [Sub]Versioning Library!
http://hg4j.com/ - Java Mercurial Library!
http://sqljet.com/ - Java SQLite Library!
On 26 December 2011 04:25, Jeffrey4l <[email protected]> wrote:
> Hi all ,
>
> Recently, I have a requirement which will download multi files from the SVN
> repository. But I don't want to use checkout, because the files may not very
> much. The checkout is a waste of time. So only the files needed is
> exported/catted.
>
> Concurrent is faster. But I don't know whether these method is thread safe?
> Or could you give me any other advise?
>
> Here is the code snippet. This method will be call in multi threads.
>
> public void doCat(SVNURL sourceUrl, SVNRevision pegRevision, SVNRevision
> revision, File target) throws SVNException, FileNotFoundException{
> SVNWCClient wcClient = _manager.getWCClient();
> FileOutputStream fos = null;
> try{
> fos = new FileOutputStream(target);
> LOG.debug(String.format("executing 'cat' for revision %d of url
> %s pegged at revision %d", revision.getNumber(), sourceUrl,
> pegRevision.getNumber()));
> wcClient.doGetFileContents(sourceUrl, pegRevision, revision,
> true, fos);
> }
> finally{
> ScmiUtil.safeClose(fos);
> }
> }
>
>
> ________________________________
> View this message in context: Is doExport and doCat method thread safe?
> Sent from the SVNKit - Users mailing list archive at Nabble.com.