|
The only pure Java Subversion library in the world!
|
|
Using SVNKit in Multithreaded Environment
When using SVNKit in multithreaded applications one can have questions like these:
Q: Can I use one SVNRepository object in multiple threads? Is SVNRepository thread-safe?
A: No, you'd better not use one SVNRepository object in multiple threads. It may appear not thread
safe. So, for every thread you have to instantiate a separate SVNRepository driver.
Another thing you should be aware about SVNRepository is that you can not call its methods
from within those handlers that are provided to its methods (like those ISVNDirEntryHandler ,
ISVNReposrterBaton , etc.), since the repository
access methods of SVNRepository are not reenterable, i.e. if
an operation has been started, it must be already finished before invoking the next operation.
The same is for committing (getCommitEditor() ): you must not make calls to your SVNRepository until you
finish editing with calling an editor's closeEdit() method.
Q: Can I use one SVN*Client object in multiple threads? Are SVN*Client objects thread-safe?
A: The answer is still no. SVN*Client objects use different handlers for processing events/data (such as
ISVNEventHandler , ISVNCommitHandler , etc.). For example, in one thread an SVN*Client object
may be dispatching an event to the registered event 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, it may cause your program to crash.
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 a 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
|