Author: brane
Date: Wed Jun 19 11:20:03 2013
New Revision: 1494550

URL: http://svn.apache.org/r1494550
Log:
On the javahl-ra branch:

Make the RemoteSession native implementation more consistent:
  - Pass JNI-typed parameters to the native C++ wrappers.
  - Use subpools of the session pool for all requests.
  - Convert arguments to C types before allocating sub-pools.

[in subversion/bindings/javahl/native]
* RemoteSession.h
  (RemoteSession::reparent,
   RemoteSession::getSessionRelativePath,
   RemoteSession::getReposRelativePath): Change argument types.
* RemoteSession.cpp: Convert types before allocaating sub-pools
   for requests, and do use sub-pools everywhere instead of
   global pools.
* org_apache_subversion_javahl_remote_RemoteSession.cpp
  (Java_org_apache_subversion_javahl_remote_RemoteSesion_reparent,
   Java_org_apache_subversion_javahl_remote_RemoteSesion_getSessionRelativePath,
   Java_org_apache_subversion_javahl_remote_RemoteSesion_getReposRelativePath):
   Do not convert JNI types to C types before calling the native implementation.

Modified:
    
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
    
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h
    
subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp

Modified: 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
URL: 
http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1494550&r1=1494549&r2=1494550&view=diff
==============================================================================
--- 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
 (original)
+++ 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
 Wed Jun 19 11:20:03 2013
@@ -273,8 +273,12 @@ RemoteSession::dispose(jobject jthis)
   SVNBase::dispose(jthis, &fid, JAVA_CLASS_REMOTE_SESSION);
 }
 
-void RemoteSession::reparent(const char* url)
+void RemoteSession::reparent(jstring jurl)
 {
+  JNIStringHolder url(jurl);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+
   SVN::Pool subPool(pool);
   SVN_JNI_ERR(svn_ra_reparent(m_session, url, subPool.getPool()), );
 }
@@ -283,8 +287,7 @@ jstring
 RemoteSession::getSessionUrl()
 {
   SVN::Pool subPool(pool);
-  const char * url;
-
+  const char* url;
   SVN_JNI_ERR(svn_ra_get_session_url(m_session, &url, subPool.getPool()), 
NULL);
 
   jstring jurl = JNIUtil::makeJString(url);
@@ -295,11 +298,14 @@ RemoteSession::getSessionUrl()
 }
 
 jstring
-RemoteSession::getSessionRelativePath(const char* url)
+RemoteSession::getSessionRelativePath(jstring jurl)
 {
+  JNIStringHolder url(jurl);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
   SVN::Pool subPool(pool);
   const char* rel_path;
-
   SVN_JNI_ERR(svn_ra_get_path_relative_to_session(
                   m_session, &rel_path, url, subPool.getPool()),
               NULL);
@@ -311,14 +317,18 @@ RemoteSession::getSessionRelativePath(co
 }
 
 jstring
-RemoteSession::getReposRelativePath(const char* url)
+RemoteSession::getReposRelativePath(jstring jurl)
 {
+  JNIStringHolder url(jurl);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
   SVN::Pool subPool(pool);
   const char* rel_path;
-
-  SVN_JNI_ERR(svn_ra_get_path_relative_to_root(
-                  m_session, &rel_path, url, subPool.getPool()),
+  SVN_JNI_ERR(svn_ra_get_path_relative_to_root(m_session, &rel_path, url,
+                                               subPool.getPool()),
               NULL);
+
   jstring jrel_path = JNIUtil::makeJString(rel_path);
   if (JNIUtil::isJavaExceptionThrown())
     return NULL;
@@ -331,7 +341,6 @@ RemoteSession::getReposUUID()
 {
   SVN::Pool subPool(pool);
   const char * uuid;
-
   SVN_JNI_ERR(svn_ra_get_uuid2(m_session, &uuid, subPool.getPool()), NULL);
 
   jstring juuid = JNIUtil::makeJString(uuid);
@@ -346,7 +355,6 @@ RemoteSession::getReposRootUrl()
 {
   SVN::Pool subPool(pool);
   const char* url;
-
   SVN_JNI_ERR(svn_ra_get_repos_root2(m_session, &url, subPool.getPool()),
               NULL);
 
@@ -362,7 +370,6 @@ RemoteSession::getLatestRevision()
 {
   SVN::Pool subPool(pool);
   svn_revnum_t rev;
-
   SVN_JNI_ERR(svn_ra_get_latest_revnum(m_session, &rev, subPool.getPool()),
               SVN_INVALID_REVNUM);
   return rev;
@@ -371,13 +378,11 @@ RemoteSession::getLatestRevision()
 jlong
 RemoteSession::getRevisionByTimestamp(jlong timestamp)
 {
-  SVN::Pool requestPool;
+  SVN::Pool subPool(pool);
   svn_revnum_t rev;
-
-  apr_time_t tm = timestamp;
-
-  SVN_JNI_ERR(svn_ra_get_dated_revision(m_session, &rev, tm,
-                                        requestPool.getPool()),
+  SVN_JNI_ERR(svn_ra_get_dated_revision(m_session, &rev,
+                                        apr_time_t(timestamp),
+                                        subPool.getPool()),
               SVN_INVALID_REVNUM);
   return rev;
 }
@@ -385,9 +390,6 @@ RemoteSession::getRevisionByTimestamp(jl
 jobject
 RemoteSession::getLocks(jstring jpath, jobject jdepth)
 {
-  SVN::Pool requestPool;
-  apr_hash_t *locks;
-
   JNIStringHolder path(jpath);
   if (JNIUtil::isExceptionThrown())
     return NULL;
@@ -396,26 +398,27 @@ RemoteSession::getLocks(jstring jpath, j
   if (JNIUtil::isExceptionThrown())
     return NULL;
 
+  SVN::Pool subPool(pool);
+  apr_hash_t *locks;
   SVN_JNI_ERR(svn_ra_get_locks2(m_session, &locks, path, depth,
-                                requestPool.getPool()),
+                                subPool.getPool()),
               NULL);
 
-  return CreateJ::LockMap(locks, requestPool.getPool());
+  return CreateJ::LockMap(locks, subPool.getPool());
 }
 
 jobject
 RemoteSession::checkPath(jstring jpath, jlong jrevision)
 {
-  SVN::Pool requestPool;
-  svn_node_kind_t kind;
-
   JNIStringHolder path(jpath);
   if (JNIUtil::isExceptionThrown())
     return NULL;
 
+  SVN::Pool subPool(pool);
+  svn_node_kind_t kind;
   SVN_JNI_ERR(svn_ra_check_path(m_session, path,
                                 svn_revnum_t(jrevision),
-                                &kind, requestPool.getPool()),
+                                &kind, subPool.getPool()),
               NULL);
 
   return EnumMapper::mapNodeKind(kind);
@@ -424,13 +427,12 @@ RemoteSession::checkPath(jstring jpath, 
 jboolean
 RemoteSession::hasCapability(jstring jcapability)
 {
-  SVN::Pool subPool(pool);
-  svn_boolean_t has;
-
   JNIStringHolder capability(jcapability);
   if (JNIUtil::isExceptionThrown())
     return false;
 
+  SVN::Pool subPool(pool);
+  svn_boolean_t has;
   SVN_JNI_ERR(svn_ra_has_capability(m_session, &has, capability,
                                     subPool.getPool()),
               false);

Modified: 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h?rev=1494550&r1=1494549&r2=1494550&view=diff
==============================================================================
--- 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h 
(original)
+++ 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h 
Wed Jun 19 11:20:03 2013
@@ -58,10 +58,10 @@ class RemoteSession : public SVNBase
 
     virtual void dispose(jobject jthis);
 
-    void reparent(const char* url);
+    void reparent(jstring jurl);
     jstring getSessionUrl();
-    jstring getSessionRelativePath(const char* url);
-    jstring getReposRelativePath(const char* url);
+    jstring getSessionRelativePath(jstring jurl);
+    jstring getReposRelativePath(jstring jurl);
     jstring getReposUUID();
     jstring getReposRootUrl();
     jlong getLatestRevision();

Modified: 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
URL: 
http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp?rev=1494550&r1=1494549&r2=1494550&view=diff
==============================================================================
--- 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
 (original)
+++ 
subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
 Wed Jun 19 11:20:03 2013
@@ -74,9 +74,7 @@ Java_org_apache_subversion_javahl_remote
   RemoteSession *ras = RemoteSession::getCppObject(jthis);
   CPPADDR_NULL_PTR(ras, );
 
-  JNIStringHolder url(jurl);
-  if (!JNIUtil::isJavaExceptionThrown())
-    ras->reparent(url);
+  ras->reparent(jurl);
 }
 
 JNIEXPORT jstring JNICALL
@@ -87,10 +85,7 @@ Java_org_apache_subversion_javahl_remote
   RemoteSession *ras = RemoteSession::getCppObject(jthis);
   CPPADDR_NULL_PTR(ras, NULL);
 
-  JNIStringHolder url(jurl);
-  if (JNIUtil::isJavaExceptionThrown())
-    return NULL;
-  return ras->getSessionRelativePath(url);
+  return ras->getSessionRelativePath(jurl);
 }
 
 JNIEXPORT jstring JNICALL
@@ -101,10 +96,7 @@ Java_org_apache_subversion_javahl_remote
   RemoteSession *ras = RemoteSession::getCppObject(jthis);
   CPPADDR_NULL_PTR(ras, NULL);
 
-  JNIStringHolder url(jurl);
-  if (JNIUtil::isJavaExceptionThrown())
-    return NULL;
-  return ras->getReposRelativePath(url);
+  return ras->getReposRelativePath(jurl);
 }
 
 JNIEXPORT jstring JNICALL


Reply via email to