You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/07/07 00:47:29 UTC

svn commit: r1500334 - in /subversion/trunk/subversion/bindings/javahl/native: RemoteSession.cpp RevpropTable.cpp

Author: brane
Date: Sat Jul  6 22:47:29 2013
New Revision: 1500334

URL: http://svn.apache.org/r1500334
Log:
Fix a bug in JavaHL where property values were not correctly terminated,
which caused random test failures.

* subversion/bindings/javahl/native/RemoteSession.cpp
  (byte_array_to_svn_string): Use svn_string_ncreate to extract the
   property value from the Java byte array.
  (RemoteSession::changeRevisionProperty): Update implementation.

* subversion/bindings/javahl/native/RevpropTable.cpp
  (RevpropTable::hash): Don't make assumptions about property values;
   use svn_string_ncreate to extract the value from the Java byte array.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
    subversion/trunk/subversion/bindings/javahl/native/RevpropTable.cpp

Modified: subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1500334&r1=1500333&r2=1500334&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp Sat Jul  6 22:47:29 2013
@@ -410,14 +410,13 @@ RemoteSession::getRevisionByTimestamp(jl
 }
 
 namespace {
-bool byte_array_to_svn_string(JNIByteArray& ary, svn_string_t& str)
+svn_string_t*
+byte_array_to_svn_string(JNIByteArray& ary, SVN::Pool& scratch_pool)
 {
   if (ary.isNull())
-    return false;
-
-  str.data = reinterpret_cast<const char*>(ary.getBytes());
-  str.len = ary.getLength();
-  return true;
+    return NULL;
+  return svn_string_ncreate(reinterpret_cast<const char*>(ary.getBytes()),
+                            ary.getLength(), scratch_pool.getPool());
 }
 } // anonymous namespace
 
@@ -438,21 +437,17 @@ RemoteSession::changeRevisionProperty(
   if (JNIUtil::isExceptionThrown())
     return;
 
-  svn_string_t str_old_value;
-  svn_string_t* const p_old_value = &str_old_value;
-  svn_string_t* const* pp_old_value = NULL;
-  if (byte_array_to_svn_string(old_value, str_old_value))
-      pp_old_value = &p_old_value;
-
-  svn_string_t str_value;
-  svn_string_t* p_value = NULL;
-  if (byte_array_to_svn_string(value, str_value))
-      p_value = &str_value;
-
   SVN::Pool subPool(pool);
+  svn_string_t* const* p_old_value = NULL;
+  svn_string_t* const str_old_value =
+    byte_array_to_svn_string(old_value, subPool);
+  if (str_old_value)
+    p_old_value = &str_old_value;
+
   SVN_JNI_ERR(svn_ra_change_rev_prop2(m_session,
                                       svn_revnum_t(jrevision),
-                                      name, pp_old_value, p_value,
+                                      name, p_old_value,
+                                      byte_array_to_svn_string(value, subPool),
                                       subPool.getPool()), );
 }
 

Modified: subversion/trunk/subversion/bindings/javahl/native/RevpropTable.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RevpropTable.cpp?rev=1500334&r1=1500333&r2=1500334&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RevpropTable.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/RevpropTable.cpp Sat Jul  6 22:47:29 2013
@@ -63,8 +63,9 @@ apr_hash_t *RevpropTable::hash(const SVN
           return NULL;
         }
 
-      svn_string_t *propval = svn_string_create(it->second.c_str(),
-                                                pool.getPool());
+      svn_string_t *propval = svn_string_ncreate(it->second.c_str(),
+                                                 it->second.size(),
+                                                 pool.getPool());
 
       apr_hash_set(revprop_table, propname, APR_HASH_KEY_STRING, propval);
     }