SVNKit The only pure Java Subversion client library in the world!
Using SVNKit in Multithreaded Environment
Either working with the SVNKit low-level API (org.tmatesoft.svn.core.io)
or with the high-level one (org.tmatesoft.svn.core.wc) you should remember
that their classes (i.e. SVNRepository, SVN*Client classes) are not thread safe.
Details follow.
Using SVNRepository
Regarding the SVNKit low-level API (SVNRepository): if SVNKit is used in a
multithreaded application, you should not use one SVNRepository object in multiple
threads. There should be one SVNRepository instance per one thread. The cause is
that the repository access methods of SVNRepository are not reenterable, i.e. if
an operation has been started, it must be finished already before invoking the
next operation (method of an SVNRepository object).
Using SVN*Client classes
Regarding the SVNKit high-level API (SVN*Client classes): although every SVN*Client
object creates a new SVNRepository driver in every case it needs an access to a repository,
you also should not use one SVN*Client object (as well as one SVNClientManager) in more than
one thread. The reason why SVN*Client objects are not thread safe is that these objects
generally use different handlers for processing events/data (such as ISVNEventHandler, ISVNCommitHandler,
ISVNStatusHandler - in case of SVNStatusClient, etc.). For example, in one thread an SVN*Client object
may be dispatching an event to a handler in the same time as another thread tries to set a new event handler
to that same SVN*Client object. What will be in result is unpredictable, but more than just a suppose it
will be a crash, unfortunately.
Another advice (well, it seems to be even more than advice:)) of using SVN*Client objects synchronously comes
from the format of a Working Copy itself: during writing operations a Working Copy is locked for the period
until the operation finishes. All other write access operations will be denied until the Working Copy is unlocked.
If you have any questions regarding SVNKit, would like to report a bug or contribute a patch, please write to
support@svnkit.com
|