You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/09/15 10:35:50 UTC

svn commit: r997228 - in /subversion/trunk/subversion/bindings/javahl/native: ClientContext.cpp ClientContext.h SVNClient.cpp

Author: hwright
Date: Wed Sep 15 08:35:50 2010
New Revision: 997228

URL: http://svn.apache.org/viewvc?rev=997228&view=rev
Log:
JavaHL: Improve error handing when fetching the client context.

* subversion/bindings/javahl/native/SVNClient.cpp:
  When fetching the client context, check for a standard Subversion error.

* subversion/bindings/javahl/native/ClientContext.h
  (getContext): Return a subversion error, and add an output parameter.

* subversion/bindings/javahl/native/ClientContext.cpp
  (getContext): Propogate encountered subvesion errors, rather than
    attempt to handle them.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/ClientContext.cpp
    subversion/trunk/subversion/bindings/javahl/native/ClientContext.h
    subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp

Modified: subversion/trunk/subversion/bindings/javahl/native/ClientContext.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ClientContext.cpp?rev=997228&r1=997227&r2=997228&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ClientContext.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ClientContext.cpp Wed Sep 15 08:35:50 2010
@@ -97,20 +97,20 @@ ClientContext::~ClientContext()
     env->DeleteGlobalRef(m_jctx);
 }
 
-svn_client_ctx_t *
-ClientContext::getContext(CommitMessage *message)
+svn_error_t *
+ClientContext::getContext(svn_client_ctx_t **ctx, CommitMessage *message)
 {
     SVN::Pool *requestPool = JNIUtil::getRequestPool();
     apr_pool_t *pool = requestPool->pool();
     svn_auth_baton_t *ab;
-    svn_client_ctx_t *ctx = persistentCtx;
-    //SVN_JNI_ERR(svn_client_create_context(&ctx, pool), NULL);
+
+    *ctx = persistentCtx;
 
     const char *configDir = m_configDir.c_str();
     if (m_configDir.length() == 0)
         configDir = NULL;
-    SVN_JNI_ERR(svn_config_get_config(&(ctx->config), configDir, pool), NULL);
-    svn_config_t *config = (svn_config_t *) apr_hash_get(ctx->config,
+    SVN_ERR(svn_config_get_config(&((*ctx)->config), configDir, pool));
+    svn_config_t *config = (svn_config_t *) apr_hash_get((*ctx)->config,
                                                          SVN_CONFIG_CATEGORY_CONFIG,
                                                          APR_HASH_KEY_STRING);
 
@@ -118,10 +118,8 @@ ClientContext::getContext(CommitMessage 
     apr_array_header_t *providers;
 
     /* Populate the registered providers with the platform-specific providers */
-    SVN_JNI_ERR(svn_auth_get_platform_specific_client_providers(&providers,
-                                                                config,
-                                                                pool),
-                NULL);
+    SVN_ERR(svn_auth_get_platform_specific_client_providers(&providers,
+                                                            config, pool));
 
     /* Use the prompter (if available) to prompt for password and cert
      * caching. */
@@ -150,11 +148,10 @@ ClientContext::getContext(CommitMessage 
     APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
 
     /* The server-cert, client-cert, and client-cert-password providers. */
-    SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
-                                                        "windows",
-                                                        "ssl_server_trust",
-                                                        pool),
-                NULL);
+    SVN_ERR(svn_auth_get_platform_specific_provider(&provider,
+                                                    "windows",
+                                                    "ssl_server_trust",
+                                                    pool));
 
     if (provider)
         APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
@@ -202,11 +199,11 @@ ClientContext::getContext(CommitMessage 
         svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD,
                                m_passWord.c_str());
 
-    ctx->auth_baton = ab;
-    ctx->log_msg_baton3 = message;
+    (*ctx)->auth_baton = ab;
+    (*ctx)->log_msg_baton3 = message;
     m_cancelOperation = false;
 
-    return ctx;
+    return SVN_NO_ERROR;
 }
 
 void

Modified: subversion/trunk/subversion/bindings/javahl/native/ClientContext.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ClientContext.h?rev=997228&r1=997227&r2=997228&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ClientContext.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ClientContext.h Wed Sep 15 08:35:50 2010
@@ -74,7 +74,7 @@ class ClientContext
 
   static svn_error_t *checkCancel(void *cancelBaton);
 
-  svn_client_ctx_t *getContext(CommitMessage *message);
+  svn_error_t *getContext(svn_client_ctx_t **ctx, CommitMessage *message);
 
   void username(const char *pi_username);
   void password(const char *pi_password);

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp?rev=997228&r1=997227&r2=997228&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp Wed Sep 15 08:35:50 2010
@@ -122,9 +122,8 @@ void SVNClient::list(const char *url, Re
                      ListCallback *callback)
 {
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_NULL_PTR_EX(url, "path or url", );
 
@@ -154,9 +153,8 @@ SVNClient::status(const char *path, svn_
 
     SVN_JNI_NULL_PTR_EX(path, "path", );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
     callback->setWcCtx(ctx->wc_ctx);
 
     Path checkedPath(path);
@@ -184,9 +182,8 @@ void SVNClient::logMessages(const char *
 
     SVN_JNI_NULL_PTR_EX(path, "path", );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     Targets target(path);
     const apr_array_header_t *targets = target.array(requestPool);
@@ -245,9 +242,8 @@ jlong SVNClient::checkout(const char *mo
     SVN_JNI_ERR(path.error_occured(), -1);
     svn_revnum_t rev;
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return -1;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), -1);
 
     SVN_JNI_ERR(svn_client_checkout3(&rev, url.c_str(),
                                      path.c_str(),
@@ -268,9 +264,8 @@ void SVNClient::remove(Targets &targets,
                        CommitCallback *callback)
 {
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(message);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     const apr_array_header_t *targets2 = targets.array(requestPool);
     SVN_JNI_ERR(targets.error_occured(), );
@@ -288,9 +283,8 @@ void SVNClient::revert(const char *path,
 
     SVN_JNI_NULL_PTR_EX(path, "path", );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     Targets target(path);
     const apr_array_header_t *targets = target.array(requestPool);
@@ -310,9 +304,8 @@ void SVNClient::add(const char *path,
 
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), );
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_add4(intPath.c_str(), depth, force,
                                 no_ignore, add_parents, ctx,
@@ -326,10 +319,9 @@ jlongArray SVNClient::update(Targets &ta
 {
     SVN::Pool requestPool;
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
     apr_array_header_t *revs;
-    if (ctx == NULL)
-        return NULL;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), NULL);
 
     const apr_array_header_t *array = targets.array(requestPool);
     SVN_JNI_ERR(targets.error_occured(), NULL);
@@ -367,9 +359,8 @@ void SVNClient::commit(Targets &targets,
     SVN::Pool requestPool;
     const apr_array_header_t *targets2 = targets.array(requestPool);
     SVN_JNI_ERR(targets.error_occured(), );
-    svn_client_ctx_t *ctx = context.getContext(message);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_commit5(targets2, depth,
                                    noUnlock, keepChangelist,
@@ -398,9 +389,8 @@ void SVNClient::copy(CopySources &copySo
     Path destinationPath(destPath);
     SVN_JNI_ERR(destinationPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(message);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_copy6(srcs, destinationPath.c_str(),
                                  copyAsChild, makeParents, ignoreExternals,
@@ -422,9 +412,8 @@ void SVNClient::move(Targets &srcPaths, 
     Path destinationPath(destPath);
     SVN_JNI_ERR(destinationPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(message);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_move6((apr_array_header_t *) srcs,
                                  destinationPath.c_str(), force, moveAsChild,
@@ -438,9 +427,8 @@ void SVNClient::mkdir(Targets &targets, 
                       CommitCallback *callback)
 {
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(message);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     const apr_array_header_t *targets2 = targets.array(requestPool);
     SVN_JNI_ERR(targets.error_occured(), );
@@ -458,9 +446,8 @@ void SVNClient::cleanup(const char *path
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_cleanup(intPath.c_str(), ctx, requestPool.pool()),);
 }
@@ -472,9 +459,8 @@ void SVNClient::resolve(const char *path
     SVN_JNI_NULL_PTR_EX(path, "path", );
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), );
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_resolve(intPath.c_str(), depth, choice,
                                    ctx, requestPool.pool()), );
@@ -493,9 +479,8 @@ jlong SVNClient::doExport(const char *sr
     Path destinationPath(destPath);
     SVN_JNI_ERR(destinationPath.error_occured(), -1);
     svn_revnum_t rev;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return -1;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), -1);
 
     SVN_JNI_ERR(svn_client_export4(&rev, sourcePath.c_str(),
                                    destinationPath.c_str(),
@@ -526,9 +511,8 @@ jlong SVNClient::doSwitch(const char *pa
     SVN_JNI_ERR(intPath.error_occured(), -1);
 
     svn_revnum_t rev;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return -1;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), -1);
 
     SVN_JNI_ERR(svn_client_switch2(&rev, intPath.c_str(),
                                    intUrl.c_str(),
@@ -558,9 +542,8 @@ void SVNClient::doImport(const char *pat
     Path intUrl(url);
     SVN_JNI_ERR(intUrl.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(message);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_import4(intPath.c_str(), intUrl.c_str(), depth,
                                    noIgnore, ignoreUnknownNodeTypes,
@@ -573,9 +556,8 @@ jobject
 SVNClient::suggestMergeSources(const char *path, Revision &pegRevision)
 {
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return NULL;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), NULL);
 
     apr_array_header_t *sources;
     SVN_JNI_ERR(svn_client_suggest_merge_sources(&sources, path,
@@ -604,9 +586,8 @@ void SVNClient::merge(const char *path1,
     Path srcPath2 = path2;
     SVN_JNI_ERR(srcPath2.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_merge3(srcPath1.c_str(), revision1.revision(),
                                   srcPath2.c_str(), revision2.revision(),
@@ -630,9 +611,8 @@ void SVNClient::merge(const char *path, 
     Path srcPath(path);
     SVN_JNI_ERR(srcPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     apr_array_header_t *ranges =
       apr_array_make(requestPool.pool(), rangesToMerge.size(),
@@ -685,9 +665,8 @@ void SVNClient::mergeReintegrate(const c
     Path srcPath(path);
     SVN_JNI_ERR(srcPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_merge_reintegrate(srcPath.c_str(),
                                              pegRevision.revision(),
@@ -702,9 +681,8 @@ SVNClient::getMergeinfo(const char *targ
     SVN::Pool requestPool;
     JNIEnv *env = JNIUtil::getEnv();
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return NULL;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), NULL);
 
     svn_mergeinfo_t mergeinfo;
     Path intLocalTarget(target);
@@ -779,9 +757,8 @@ void SVNClient::getMergeinfoLog(int type
 {
     SVN::Pool requestPool;
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_NULL_PTR_EX(pathOrURL, "path or url", );
     Path urlPath(pathOrURL);
@@ -819,9 +796,8 @@ jbyteArray SVNClient::propertyGet(const 
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), NULL);
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return NULL;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), NULL);
 
     apr_hash_t *props;
     SVN_JNI_ERR(svn_client_propget3(&props, name,
@@ -855,9 +831,8 @@ void SVNClient::properties(const char *p
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_proplist3(intPath.c_str(), pegRevision.revision(),
                                      revision.revision(), depth,
@@ -886,9 +861,8 @@ void SVNClient::propertySet(const char *
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_propset4(name, val, intPath.c_str(),
                                     depth, force, SVN_INVALID_REVNUM,
@@ -918,9 +892,8 @@ void SVNClient::diff(const char *target1
         SVN_JNI_NULL_PTR_EX(target2, "target2", );
 
     SVN_JNI_NULL_PTR_EX(outfileName, "outfileName", );
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     Path path1(target1);
     SVN_JNI_ERR(path1.error_occured(), );
@@ -1045,9 +1018,8 @@ SVNClient::diffSummarize(const char *tar
     SVN_JNI_NULL_PTR_EX(target1, "target1", );
     SVN_JNI_NULL_PTR_EX(target2, "target2", );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     Path path1(target1);
     SVN_JNI_ERR(path1.error_occured(), );
@@ -1074,9 +1046,8 @@ SVNClient::diffSummarize(const char *tar
 
     SVN_JNI_NULL_PTR_EX(target, "target", );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     Path path(target);
     SVN_JNI_ERR(path.error_occured(), );
@@ -1219,9 +1190,8 @@ svn_stream_t *SVNClient::createReadStrea
     }
     else
     {
-        svn_client_ctx_t *ctx = context.getContext(NULL);
-        if (ctx == NULL)
-            return NULL;
+        svn_client_ctx_t *ctx;
+        SVN_JNI_ERR(context.getContext(&ctx, NULL), NULL);
 
         svn_stringbuf_t *buf = svn_stringbuf_create("", pool);
         read_stream = svn_stream_from_stringbuf(buf, pool);
@@ -1243,9 +1213,8 @@ jbyteArray SVNClient::revProperty(const 
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), NULL);
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return NULL;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), NULL);
 
     const char *URL;
     svn_string_t *propval;
@@ -1288,9 +1257,8 @@ void SVNClient::relocate(const char *fro
     Path intTo(to);
     SVN_JNI_ERR(intTo.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_relocate(intPath.c_str(), intFrom.c_str(),
                                     intTo.c_str(), recurse, ctx,
@@ -1308,9 +1276,8 @@ void SVNClient::blame(const char *path, 
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_blame5(intPath.c_str(), pegRevision.revision(),
                                   revisionStart.revision(),
@@ -1326,7 +1293,8 @@ void SVNClient::addToChangelist(Targets 
                                 svn_depth_t depth, StringArray &changelists)
 {
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     const apr_array_header_t *srcs = srcPaths.array(requestPool);
     SVN_JNI_ERR(srcPaths.error_occured(), );
@@ -1340,7 +1308,8 @@ void SVNClient::removeFromChangelists(Ta
                                       StringArray &changelists)
 {
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     const apr_array_header_t *srcs = srcPaths.array(requestPool);
     SVN_JNI_ERR(srcPaths.error_occured(), );
@@ -1356,7 +1325,8 @@ void SVNClient::getChangelists(const cha
                                ChangelistCallback *callback)
 {
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_get_changelists(rootPath,
                                            changelists.array(requestPool),
@@ -1370,7 +1340,8 @@ void SVNClient::lock(Targets &targets, c
     SVN::Pool requestPool;
     const apr_array_header_t *targetsApr = targets.array(requestPool);
     SVN_JNI_ERR(targets.error_occured(), );
-    svn_client_ctx_t *ctx = context.getContext(NULL);
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     SVN_JNI_ERR(svn_client_lock(targetsApr, comment, force, ctx,
                                 requestPool.pool()), );
@@ -1382,7 +1353,8 @@ void SVNClient::unlock(Targets &targets,
 
     const apr_array_header_t *targetsApr = targets.array(requestPool);
     SVN_JNI_ERR(targets.error_occured(), );
-    svn_client_ctx_t *ctx = context.getContext(NULL);
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
     SVN_JNI_ERR(svn_client_unlock((apr_array_header_t*)targetsApr, force,
                                   ctx, requestPool.pool()), );
 }
@@ -1397,9 +1369,8 @@ void SVNClient::setRevProperty(const cha
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     const char *URL;
     SVN_JNI_ERR(svn_client_url_from_path2(&URL, intPath.c_str(), ctx,
@@ -1436,9 +1407,9 @@ jstring SVNClient::getVersionInfo(const 
     SVN_JNI_ERR(intPath.error_occured(), NULL);
 
     int wc_format;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return NULL;
+
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), NULL);
     SVN_JNI_ERR(svn_wc_check_wc2(&wc_format, ctx->wc_ctx, intPath.c_str(),
                                  requestPool.pool()),
                 NULL);
@@ -1495,9 +1466,8 @@ void SVNClient::upgrade(const char *path
     SVN::Pool requestPool;
     SVN_JNI_NULL_PTR_EX(path, "path", );
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     Path checkedPath(path);
     SVN_JNI_ERR(checkedPath.error_occured(), );
@@ -1513,7 +1483,9 @@ jobject SVNClient::revProperties(const c
     Path intPath(path);
     SVN_JNI_ERR(intPath.error_occured(), NULL);
 
-    svn_client_ctx_t *ctx = context.getContext(NULL);
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), NULL);
+
     const char *URL;
     svn_revnum_t set_rev;
     SVN_JNI_ERR(svn_client_url_from_path2(&URL, intPath.c_str(), ctx,
@@ -1546,9 +1518,8 @@ SVNClient::info2(const char *path, Revis
     SVN_JNI_NULL_PTR_EX(path, "path", );
 
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     Path checkedPath(path);
     SVN_JNI_ERR(checkedPath.error_occured(), );
@@ -1571,9 +1542,8 @@ SVNClient::patch(const char *patchPath, 
     SVN_JNI_NULL_PTR_EX(targetPath, "targetPath", );
 
     SVN::Pool requestPool;
-    svn_client_ctx_t *ctx = context.getContext(NULL);
-    if (ctx == NULL)
-        return;
+    svn_client_ctx_t *ctx;
+    SVN_JNI_ERR(context.getContext(&ctx, NULL), );
 
     Path checkedPatchPath(patchPath);
     SVN_JNI_ERR(checkedPatchPath.error_occured(), );