Author: brane
Date: Wed Jan 15 14:11:16 2014
New Revision: 1558389
URL: http://svn.apache.org/r1558389
Log:
Remove an uncessary svn_ra initialization from JavahL, and add a test
case for parallel RA session usage.
[in subversion/bindings/javahl]
* native/RemoteSession.cpp (RemoteSession::open): Do not call svn_ra_initialize.
* native/JNIUtil.cpp (JNIUtil::JNIGlobalInit):
Catch and report errors from svn_fs_initialize and svn_ra_initialize.
* tests/org/apache/subversion/javahl/SVNRemoteTests.java
(SVNRemoteTests.testParallelOpen): New test case.
Modified:
subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp
subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
Modified: subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1558389&r1=1558388&r2=1558389&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp Wed Jan 15
14:11:16 2014
@@ -150,8 +150,19 @@ bool JNIUtil::JNIGlobalInit(JNIEnv *env)
}
svn_utf_initialize2(FALSE, g_pool); /* Optimize character conversions */
- svn_fs_initialize(g_pool); /* Avoid some theoretical issues */
- svn_ra_initialize(g_pool);
+
+ // Initialize the libraries we use
+ err = svn_fs_initialize(g_pool);
+ if (!err)
+ err = svn_ra_initialize(g_pool);
+ if (err)
+ {
+ if (stderr && err->message)
+ fprintf(stderr, "%s", err->message);
+
+ svn_error_clear(err);
+ return FALSE;
+ }
/* We shouldn't fill the JVMs memory with FS cache data unless
explictly requested. And we don't either, because the caches get
Modified: subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1558389&r1=1558388&r2=1558389&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp Wed
Jan 15 14:11:16 2014
@@ -129,16 +129,6 @@ RemoteSession::open(jint jretryAttempts,
Prompter*& prompter, jobject jprogress,
jobject jcfgcb, jobject jtunnelcb)
{
- /*
- * Initialize ra layer if we have not done so yet
- */
- static bool initialized = false;
- if (!initialized)
- {
- SVN_JNI_ERR(svn_ra_initialize(JNIUtil::getPool()), NULL);
- initialized = true;
- }
-
RemoteSession* session = new RemoteSession(
jretryAttempts, url, uuid, configDirectory,
usernameStr, passwordStr, prompter, jcfgcb, jtunnelcb);
Modified:
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java?rev=1558389&r1=1558388&r2=1558389&view=diff
==============================================================================
---
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
(original)
+++
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
Wed Jan 15 14:11:16 2014
@@ -1356,4 +1356,43 @@ public class SVNRemoteTests extends SVNT
assertEquals("/iota", rev.getPath());
assertFalse(rev.isResultOfMerge());
}
+
+ // This test is a result of a threading bug that was identified in
+ // serf-1.3.2 and earlier. The net result was that opening two RA
+ // sessions to an https:// URL in two parallel threads would cause
+ // a crash in serf, due to the OpenSSL library not being
+ // initialized in a single-threaded context.
+ //
+ // The problem does not appear to exist with other RA methods, but
+ // the test is here just in case someone is actually pedantic
+ // enough to test JavaHL with an HTTPS setup.
+ public void testParallelOpen() throws Exception
+ {
+ final Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ ISVNRemote session = null;
+ try {
+ session = getSession();
+ assertEquals(1, session.getLatestRevision());
+ }
+ catch (ClientException ex) {
+ throw new RuntimeException(ex);
+ }
+ finally {
+ if (session != null)
+ session.dispose();
+ }
+ }
+ };
+
+ Thread thread1 = new Thread(runnable);
+ Thread thread2 = new Thread(runnable);
+
+ thread1.start();
+ thread2.start();
+
+ thread1.join();
+ thread2.join();
+ }
}