You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by sv...@apache.org on 2015/05/01 06:00:27 UTC

svn commit: r1677095 - in /subversion/branches/1.9.x: ./ subversion/bindings/javahl/native/ subversion/bindings/javahl/src/org/apache/subversion/javahl/ subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/

Author: svn-role
Date: Fri May  1 04:00:27 2015
New Revision: 1677095

URL: http://svn.apache.org/r1677095
Log:
Merge the r1675771 group from trunk:

 * r1675771, r1676555, r1676564, r1676769
   Fix a bunch of native-memory leaks in JavaHL.
   Justification:
     Memory leaks are bad. This fix should go into .0 because
     it affects JavaHL APIs that are new in 1.9 and also some
     existing 1.8 APIs that previously did not leak.
   Notes:
     Soak restart is not needed after this fix, IMO.
   Votes:
     +1: brane, philip

Modified:
    subversion/branches/1.9.x/   (props changed)
    subversion/branches/1.9.x/STATUS
    subversion/branches/1.9.x/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/branches/1.9.x/subversion/bindings/javahl/native/EditorProxy.cpp
    subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.cpp
    subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.hpp
    subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java
    subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java

Propchange: subversion/branches/1.9.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May  1 04:00:27 2015
@@ -91,4 +91,4 @@
 /subversion/branches/verify-at-commit:1462039-1462408
 /subversion/branches/verify-keep-going:1439280-1546110
 /subversion/branches/wc-collate-path:1402685-1480384
-/subversion/trunk:1660545-1660547,1660549-1662901,1663003,1663183-1663184,1663338,1663347,1663355,1663374,1663450,1663530,1663671,1663697,1663706,1663738,1663749,1663791,1663991,1664035,1664078,1664080,1664084-1664085,1664187,1664191,1664193,1664200,1664344,1664476,1664480-1664481,1664483,1664489-1664490,1664507,1664520-1664521,1664523,1664526-1664527,1664531-1664532,1664588,1664593-1664594,1664596,1664653,1664664,1664672,1664674,1664684,1664927,1664938-1664940,1664978,1664984,1664997,1665164,1665195,1665213,1665259,1665318,1665437-1665438,1665609,1665611-1665612,1665845,1665850,1665852,1665886,1665894,1665896,1666096,1666258,1666270,1666272,1666379,1666449,1666690,1666832,1666851,1666965,1667101,1667106-1667107,1667120,1667228,1667233-1667235,1667249-1667250,1667258,1667290,1667301,1667471,1667691-1667693,1667699-1667700,1667715,1667941,1667976,1668320,1668598-1668600,1668602-1668603,1668607-1668608,1668618,1669743,1669746,1669749,1669945,1670139,1670149,1670152,1670329,1670337,167
 0347,1670353,1671164,1671388,1672295,1672311,1672372,1672404,1672511-1672512,1672578,1672728,1673044,1673062-1673063,1673065,1673153,1673170,1673172,1673197,1673202,1673204,1673228,1673282,1673445,1673691-1673692,1673746,1673785,1673803,1674015,1674032,1674170,1674406,1674487,1674522,1674580,1674627,1674891,1676665
+/subversion/trunk:1660545-1660547,1660549-1662901,1663003,1663183-1663184,1663338,1663347,1663355,1663374,1663450,1663530,1663671,1663697,1663706,1663738,1663749,1663791,1663991,1664035,1664078,1664080,1664084-1664085,1664187,1664191,1664193,1664200,1664344,1664476,1664480-1664481,1664483,1664489-1664490,1664507,1664520-1664521,1664523,1664526-1664527,1664531-1664532,1664588,1664593-1664594,1664596,1664653,1664664,1664672,1664674,1664684,1664927,1664938-1664940,1664978,1664984,1664997,1665164,1665195,1665213,1665259,1665318,1665437-1665438,1665609,1665611-1665612,1665845,1665850,1665852,1665886,1665894,1665896,1666096,1666258,1666270,1666272,1666379,1666449,1666690,1666832,1666851,1666965,1667101,1667106-1667107,1667120,1667228,1667233-1667235,1667249-1667250,1667258,1667290,1667301,1667471,1667691-1667693,1667699-1667700,1667715,1667941,1667976,1668320,1668598-1668600,1668602-1668603,1668607-1668608,1668618,1669743,1669746,1669749,1669945,1670139,1670149,1670152,1670329,1670337,167
 0347,1670353,1671164,1671388,1672295,1672311,1672372,1672404,1672511-1672512,1672578,1672728,1673044,1673062-1673063,1673065,1673153,1673170,1673172,1673197,1673202,1673204,1673228,1673282,1673445,1673691-1673692,1673746,1673785,1673803,1674015,1674032,1674170,1674406,1674487,1674522,1674580,1674627,1674891,1675771,1676555,1676564,1676665,1676769

Modified: subversion/branches/1.9.x/STATUS
URL: http://svn.apache.org/viewvc/subversion/branches/1.9.x/STATUS?rev=1677095&r1=1677094&r2=1677095&view=diff
==============================================================================
--- subversion/branches/1.9.x/STATUS (original)
+++ subversion/branches/1.9.x/STATUS Fri May  1 04:00:27 2015
@@ -102,14 +102,3 @@ Veto-blocked changes:
 
 Approved changes:
 =================
-
- * r1675771, r1676555, r1676564, r1676769
-   Fix a bunch of native-memory leaks in JavaHL.
-   Justification:
-     Memory leaks are bad. This fix should go into .0 because
-     it affects JavaHL APIs that are new in 1.9 and also some
-     existing 1.8 APIs that previously did not leak.
-   Notes:
-     Soak restart is not needed after this fix, IMO.
-   Votes:
-     +1: brane, philip

Modified: subversion/branches/1.9.x/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/1.9.x/subversion/bindings/javahl/native/CreateJ.cpp?rev=1677095&r1=1677094&r2=1677095&view=diff
==============================================================================
--- subversion/branches/1.9.x/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/branches/1.9.x/subversion/bindings/javahl/native/CreateJ.cpp Fri May  1 04:00:27 2015
@@ -1158,17 +1158,18 @@ void fill_property_map(jobject map,
         if (JNIUtil::isJavaExceptionThrown())
           return;
 
-        jbyteArray jpropVal = (!val ? NULL
-                               : JNIUtil::makeJByteArray(val));
+        jbyteArray jpropVal = (val ? JNIUtil::makeJByteArray(val) : NULL);
         if (JNIUtil::isJavaExceptionThrown())
           return;
 
-        m_env->CallObjectMethod(m_map, m_put_mid, jpropName, jpropVal);
+        jobject ret = m_env->CallObjectMethod(m_map, m_put_mid,
+                                              jpropName, jpropVal);
         if (JNIUtil::isJavaExceptionThrown())
           return;
 
-        m_env->DeleteLocalRef(jpropName);
+        m_env->DeleteLocalRef(ret);
         m_env->DeleteLocalRef(jpropVal);
+        m_env->DeleteLocalRef(jpropName);
       }
 
     JNIEnv*& m_env;
@@ -1214,6 +1215,7 @@ void fill_property_map(jobject map,
             POP_AND_RETURN_NOTHING();
         }
     }
+  POP_AND_RETURN_NOTHING();
 }
 
 jobject property_map(apr_hash_t *prop_hash, apr_array_header_t* prop_diffs,

Modified: subversion/branches/1.9.x/subversion/bindings/javahl/native/EditorProxy.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/1.9.x/subversion/bindings/javahl/native/EditorProxy.cpp?rev=1677095&r1=1677094&r2=1677095&view=diff
==============================================================================
--- subversion/branches/1.9.x/subversion/bindings/javahl/native/EditorProxy.cpp (original)
+++ subversion/branches/1.9.x/subversion/bindings/javahl/native/EditorProxy.cpp Fri May  1 04:00:27 2015
@@ -151,29 +151,32 @@ EditorProxy::cb_add_directory(void *bato
                               apr_pool_t *scratch_pool)
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_add_directory('%s')\n", relpath);
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "addDirectory",
-                            "(Ljava/lang/String;"
-                            "Ljava/lang/Iterable;"
-                            "Ljava/util/Map;J)V"));
-
-  jstring jrelpath = JNIUtil::makeJString(relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jchildren = (!children ? NULL : CreateJ::StringSet(children));
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jrelpath, jchildren, jprops,
-                                        jlong(replaces_rev)),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "addDirectory",
+                                "(Ljava/lang/String;"
+                                "Ljava/lang/Iterable;"
+                                "Ljava/util/Map;J)V"));
+
+      jstring jrelpath = JNIUtil::makeJString(relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jchildren = (!children ? NULL : CreateJ::StringSet(children));
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jrelpath, jchildren, jprops,
+                         jlong(replaces_rev));
+    });
   return SVN_NO_ERROR;
 }
 
@@ -187,36 +190,37 @@ EditorProxy::cb_add_file(void *baton,
                          apr_pool_t *scratch_pool)
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_add_file('%s')\n", relpath);
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "addFile",
-                            "(Ljava/lang/String;"
-                            "L"JAVA_PACKAGE"/types/Checksum;"
-                            "Ljava/io/InputStream;"
-                            "Ljava/util/Map;J)V"));
-
-  jstring jrelpath = JNIUtil::makeJString(relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jchecksum = CreateJ::Checksum(checksum);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jcontents = NULL;
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  if (contents != NULL)
-    SVN_JAVAHL_CATCH(Java::Env(), SVN_ERR_RA_SVN_EDIT_ABORTED,
-                     jcontents = wrap_input_stream(contents));
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jrelpath, jchecksum, jcontents,
-                                        jprops, jlong(replaces_rev)),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "addFile",
+                                "(Ljava/lang/String;"
+                                "L"JAVA_PACKAGE"/types/Checksum;"
+                                "Ljava/io/InputStream;"
+                                "Ljava/util/Map;J)V"));
+
+      jstring jrelpath = JNIUtil::makeJString(relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jchecksum = CreateJ::Checksum(checksum);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      jobject jcontents = NULL;
+      if (contents != NULL)
+        jcontents = wrap_input_stream(contents);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jrelpath, jchecksum, jcontents,
+                         jprops, jlong(replaces_rev));
+    });
   return SVN_NO_ERROR;
 }
 
@@ -229,29 +233,32 @@ EditorProxy::cb_add_symlink(void *baton,
                             apr_pool_t *scratch_pool)
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_add_symlink('%s')\n", relpath);
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "addSymlink",
-                            "(Ljava/lang/String;"
-                            "Ljava/lang/String;"
-                            "Ljava/util/Map;J)V"));
-
-  jstring jrelpath = JNIUtil::makeJString(relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jstring jtarget = JNIUtil::makeJString(target);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jrelpath, jtarget, jprops,
-                                        jlong(replaces_rev)),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "addSymlink",
+                                "(Ljava/lang/String;"
+                                "Ljava/lang/String;"
+                                "Ljava/util/Map;J)V"));
+
+      jstring jrelpath = JNIUtil::makeJString(relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jstring jtarget = JNIUtil::makeJString(target);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jrelpath, jtarget, jprops,
+                         jlong(replaces_rev));
+    });
   return SVN_NO_ERROR;
 }
 
@@ -263,27 +270,30 @@ EditorProxy::cb_add_absent(void *baton,
                            apr_pool_t *scratch_pool)
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_add_absent('%s')\n", relpath);
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "addAbsent",
-                            "(Ljava/lang/String;"
-                            "L"JAVA_PACKAGE"/types/NodeKind;"
-                            "J)V"));
-
-  jstring jrelpath = JNIUtil::makeJString(relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jkind = EnumMapper::mapNodeKind(kind);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jrelpath, jkind,
-                                        jlong(replaces_rev)),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "addAbsent",
+                                "(Ljava/lang/String;"
+                                "L"JAVA_PACKAGE"/types/NodeKind;"
+                                "J)V"));
+
+      jstring jrelpath = JNIUtil::makeJString(relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jkind = EnumMapper::mapNodeKind(kind);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jrelpath, jkind,
+                         jlong(replaces_rev));
+    });
   return SVN_NO_ERROR;
 }
 
@@ -297,29 +307,32 @@ EditorProxy::cb_alter_directory(void *ba
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_alter_directory('%s', r%lld)\n",
   //DEBUG:        relpath, static_cast<long long>(revision));
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "alterDirectory",
-                            "(Ljava/lang/String;J"
-                            "Ljava/lang/Iterable;"
-                            "Ljava/util/Map;)V"));
-
-  jstring jrelpath = JNIUtil::makeJString(relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jchildren = (!children ? NULL : CreateJ::StringSet(children));
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jrelpath, jlong(revision),
-                                        jchildren, jprops),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "alterDirectory",
+                                "(Ljava/lang/String;J"
+                                "Ljava/lang/Iterable;"
+                                "Ljava/util/Map;)V"));
+
+      jstring jrelpath = JNIUtil::makeJString(relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jchildren = (!children ? NULL : CreateJ::StringSet(children));
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jrelpath, jlong(revision),
+                         jchildren, jprops);
+    });
   return SVN_NO_ERROR;
 }
 
@@ -334,36 +347,37 @@ EditorProxy::cb_alter_file(void *baton,
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_alter_file('%s', r%lld)\n",
   //DEBUG:        relpath, static_cast<long long>(revision));
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "alterFile",
-                            "(Ljava/lang/String;J"
-                            "L"JAVA_PACKAGE"/types/Checksum;"
-                            "Ljava/io/InputStream;"
-                            "Ljava/util/Map;)V"));
-
-  jstring jrelpath = JNIUtil::makeJString(relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jchecksum = CreateJ::Checksum(checksum);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jcontents = NULL;
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  if (contents != NULL)
-    SVN_JAVAHL_CATCH(Java::Env(), SVN_ERR_RA_SVN_EDIT_ABORTED,
-                     jcontents = wrap_input_stream(contents));
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jrelpath, jlong(revision),
-                                        jchecksum, jcontents, jprops),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "alterFile",
+                                "(Ljava/lang/String;J"
+                                "L"JAVA_PACKAGE"/types/Checksum;"
+                                "Ljava/io/InputStream;"
+                                "Ljava/util/Map;)V"));
+
+      jstring jrelpath = JNIUtil::makeJString(relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jchecksum = CreateJ::Checksum(checksum);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      jobject jcontents = NULL;
+      if (contents != NULL)
+        jcontents = wrap_input_stream(contents);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jrelpath, jlong(revision),
+                         jchecksum, jcontents, jprops);
+    });
   return SVN_NO_ERROR;
 }
 
@@ -377,29 +391,32 @@ EditorProxy::cb_alter_symlink(void *bato
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_alter_symlink('%s', r%lld)\n",
   //DEBUG:        relpath, static_cast<long long>(revision));
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "alterSymlink",
-                            "(Ljava/lang/String;J"
-                            "Ljava/lang/String;"
-                            "Ljava/util/Map;)V"));
-
-  jstring jrelpath = JNIUtil::makeJString(relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jstring jtarget = JNIUtil::makeJString(target);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jrelpath, jlong(revision),
-                                        jtarget, jprops),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "alterSymlink",
+                                "(Ljava/lang/String;J"
+                                "Ljava/lang/String;"
+                                "Ljava/util/Map;)V"));
+
+      jstring jrelpath = JNIUtil::makeJString(relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jstring jtarget = JNIUtil::makeJString(target);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jobject jprops = CreateJ::PropertyMap(props, scratch_pool);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jrelpath, jlong(revision),
+                         jtarget, jprops);
+    });
   return SVN_NO_ERROR;
 }
 
@@ -411,21 +428,24 @@ EditorProxy::cb_delete(void *baton,
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_delete('%s', r%lld)\n",
   //DEBUG:        relpath, static_cast<long long>(revision));
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "delete",
+                                "(Ljava/lang/String;J)V"));
+
+      jstring jrelpath = JNIUtil::makeJString(relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
 
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "delete",
-                            "(Ljava/lang/String;J)V"));
-
-  jstring jrelpath = JNIUtil::makeJString(relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid, jrelpath),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+      env.CallVoidMethod(ep->m_jeditor, mid, jrelpath);
+    });
   return SVN_NO_ERROR;
 }
 
@@ -439,26 +459,29 @@ EditorProxy::cb_copy(void *baton,
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_copy('%s', r%lld, '%s')\n",
   //DEBUG:        src_relpath, static_cast<long long>(src_revision), dst_relpath);
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "copy",
-                            "(Ljava/lang/String;J"
-                            "Ljava/lang/String;J)V"));
-
-  jstring jsrc_relpath = JNIUtil::makeJString(src_relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jstring jdst_relpath = JNIUtil::makeJString(dst_relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jsrc_relpath, jlong(src_revision),
-                                        jdst_relpath, jlong(replaces_rev)),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "copy",
+                                "(Ljava/lang/String;J"
+                                "Ljava/lang/String;J)V"));
+
+      jstring jsrc_relpath = JNIUtil::makeJString(src_relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jstring jdst_relpath = JNIUtil::makeJString(dst_relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jsrc_relpath, jlong(src_revision),
+                         jdst_relpath, jlong(replaces_rev));
+    });
   return SVN_NO_ERROR;
 }
 
@@ -472,26 +495,29 @@ EditorProxy::cb_move(void *baton,
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_move('%s', r%lld, '%s')\n",
   //DEBUG:        src_relpath, static_cast<long long>(src_revision), dst_relpath);
-
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "move",
-                            "(Ljava/lang/String;J"
-                            "Ljava/lang/String;J)V"));
-
-  jstring jsrc_relpath = JNIUtil::makeJString(src_relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-  jstring jdst_relpath = JNIUtil::makeJString(dst_relpath);
-  SVN_JNI_CATCH(,SVN_ERR_RA_SVN_EDIT_ABORTED);
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid,
-                                        jsrc_relpath, jlong(src_revision),
-                                        jdst_relpath, jlong(replaces_rev)),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "move",
+                                "(Ljava/lang/String;J"
+                                "Ljava/lang/String;J)V"));
+
+      jstring jsrc_relpath = JNIUtil::makeJString(src_relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+      jstring jdst_relpath = JNIUtil::makeJString(dst_relpath);
+      SVN_JAVAHL_OLDSTYLE_EXCEPTION_CHECK(env);
+
+      env.CallVoidMethod(ep->m_jeditor, mid,
+                         jsrc_relpath, jlong(src_revision),
+                         jdst_relpath, jlong(replaces_rev));
+    });
   return SVN_NO_ERROR;
 }
 
@@ -499,18 +525,21 @@ svn_error_t*
 EditorProxy::cb_complete(void *baton, apr_pool_t *scratch_pool)
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_complete()\n");
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+      ep->m_valid = false;
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "complete", "()V"));
 
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-  ep->m_valid = false;
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "complete", "()V"));
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+      env.CallVoidMethod(ep->m_jeditor, mid);
+    });
   return SVN_NO_ERROR;
 }
 
@@ -518,17 +547,20 @@ svn_error_t*
 EditorProxy::cb_abort(void *baton, apr_pool_t *scratch_pool)
 {
   //DEBUG:fprintf(stderr, "  (n) EditorProxy::cb_abort()\n");
+  const ::Java::Env env;
+  SVN_JAVAHL_CATCH(env, SVN_ERR_RA_SVN_EDIT_ABORTED,
+    {
+      ::Java::LocalFrame frame(env);
+
+      EditorProxy* const ep = static_cast<EditorProxy*>(baton);
+      if (!ep || !ep->m_valid)
+        return invalid_editor();
+      ep->m_valid = false;
+
+      static jmethodID mid = 0;
+      SVN_ERR(get_editor_method(mid, "abort", "()V"));
 
-  EditorProxy* const ep = static_cast<EditorProxy*>(baton);
-  if (!ep || !ep->m_valid)
-    return invalid_editor();
-  ep->m_valid = false;
-
-  static jmethodID mid = 0;
-  SVN_ERR(get_editor_method(mid, "abort", "()V"));
-
-  SVN_JNI_CATCH(
-      JNIUtil::getEnv()->CallVoidMethod(ep->m_jeditor, mid),
-      SVN_ERR_RA_SVN_EDIT_ABORTED);
+      env.CallVoidMethod(ep->m_jeditor, mid);
+    });
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.cpp?rev=1677095&r1=1677094&r2=1677095&view=diff
==============================================================================
--- subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.cpp (original)
+++ subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.cpp Fri May  1 04:00:27 2015
@@ -45,16 +45,23 @@ void NativeInputStream::set_stream(svn_s
 }
 
 NativeInputStream*
-NativeInputStream::get_self(::Java::Env env, jobject jthis)
+NativeInputStream::get_self_unsafe(::Java::Env env, jobject jthis)
 {
   jfieldID fid_cppaddr = NULL;
   const jlong cppaddr =
     findCppAddrForJObject(jthis, &fid_cppaddr, m_class_name);
-  if (!cppaddr)
-    ::Java::NullPointerException(env).raise(_("this [C++]"));
   return reinterpret_cast<NativeInputStream*>(cppaddr);
 }
 
+NativeInputStream*
+NativeInputStream::get_self(::Java::Env env, jobject jthis)
+{
+  NativeInputStream* self = get_self_unsafe(env, jthis);
+  if (!self)
+    ::Java::NullPointerException(env).raise(_("this [C++]"));
+  return self;
+}
+
 void NativeInputStream::close(::Java::Env env, jobject jthis)
 {
   SVN_JAVAHL_CHECK(env, svn_stream_close(m_stream));
@@ -149,16 +156,23 @@ void NativeOutputStream::set_stream(svn_
 }
 
 NativeOutputStream*
-NativeOutputStream::get_self(::Java::Env env, jobject jthis)
+NativeOutputStream::get_self_unsafe(::Java::Env env, jobject jthis)
 {
   jfieldID fid_cppaddr = NULL;
   const jlong cppaddr =
     findCppAddrForJObject(jthis, &fid_cppaddr, m_class_name);
-  if (!cppaddr)
-    ::Java::NullPointerException(env).raise(_("this [C++]"));
   return reinterpret_cast<NativeOutputStream*>(cppaddr);
 }
 
+NativeOutputStream*
+NativeOutputStream::get_self(::Java::Env env, jobject jthis)
+{
+  NativeOutputStream* self = get_self_unsafe(env, jthis);
+  if (!self)
+    ::Java::NullPointerException(env).raise(_("this [C++]"));
+  return self;
+}
+
 void NativeOutputStream::close(::Java::Env env, jobject jthis)
 {
   SVN_JAVAHL_CHECK(env, svn_stream_close(m_stream));
@@ -294,6 +308,20 @@ Java_org_apache_subversion_javahl_types_
   return 0;
 }
 
+JNIEXPORT void JNICALL
+Java_org_apache_subversion_javahl_types_NativeInputStream_finalize(
+    JNIEnv* jenv, jobject jthis)
+{
+  SVN_JAVAHL_JNI_TRY(NativeInputStream, finalize)
+    {
+      JavaHL::NativeInputStream* native =
+        JavaHL::NativeInputStream::get_self_unsafe(Java::Env(jenv), jthis);
+      if (native != NULL)
+          native->finalize();
+    }
+  SVN_JAVAHL_JNI_CATCH;
+}
+
 
 // Class JavaHL::NativeOutputStream native method implementation
 #include "../include/org_apache_subversion_javahl_types_NativeOutputStream.h"
@@ -337,3 +365,17 @@ Java_org_apache_subversion_javahl_types_
     }
   SVN_JAVAHL_JNI_CATCH_TO_EXCEPTION(Java::IOException);
 }
+
+JNIEXPORT void JNICALL
+Java_org_apache_subversion_javahl_types_NativeOutputStream_finalize(
+    JNIEnv* jenv, jobject jthis)
+{
+  SVN_JAVAHL_JNI_TRY(NativeOutputStream, finalize)
+    {
+      JavaHL::NativeOutputStream* native =
+        JavaHL::NativeOutputStream::get_self_unsafe(Java::Env(jenv), jthis);
+      if (native != NULL)
+          native->finalize();
+    }
+  SVN_JAVAHL_JNI_CATCH;
+}

Modified: subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.hpp
URL: http://svn.apache.org/viewvc/subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.hpp?rev=1677095&r1=1677094&r2=1677095&view=diff
==============================================================================
--- subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.hpp (original)
+++ subversion/branches/1.9.x/subversion/bindings/javahl/native/NativeStream.hpp Fri May  1 04:00:27 2015
@@ -81,6 +81,8 @@ public:
    */
   static NativeInputStream* get_self(::Java::Env env, jobject jthis);
 
+  static NativeInputStream* get_self_unsafe(::Java::Env env, jobject jthis);
+
 public:
   /**
    * Implements @c InputStream.close().
@@ -176,6 +178,8 @@ public:
    */
   static NativeOutputStream* get_self(::Java::Env env, jobject jthis);
 
+  static NativeOutputStream* get_self_unsafe(::Java::Env env, jobject jthis);
+
 public:
   /**
    * Implements @c OutputStream.close().

Modified: subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java
URL: http://svn.apache.org/viewvc/subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java?rev=1677095&r1=1677094&r2=1677095&view=diff
==============================================================================
--- subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java (original)
+++ subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java Fri May  1 04:00:27 2015
@@ -94,7 +94,9 @@ public interface ISVNEditor
      * <code>replacesRevision</code> set accordingly <em>must</em> be used.
      * <p>
      * <b>Note:</b> The <code>contents</code> stream's lifetime must not
-     *      extend beyond the scope of this function.
+     *      extend beyond the scope of this function. An
+     *      implementation <b>must</b> close the stream after
+     *      consuming its contents.
      *
      * @throws ClientException
      */
@@ -193,7 +195,9 @@ public interface ISVNEditor
      * #addFile().
      * <p>
      * <b>Note:</b> The <code>contents</code> stream's lifetime must not
-     *      extend beyond the scope of this function.
+     *      extend beyond the scope of this function. An
+     *      implementation <b>must</b> close the stream after
+     *      consuming its contents.
      *
      * @throws ClientException
      */

Modified: subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java
URL: http://svn.apache.org/viewvc/subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java?rev=1677095&r1=1677094&r2=1677095&view=diff
==============================================================================
--- subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java (original)
+++ subversion/branches/1.9.x/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java Fri May  1 04:00:27 2015
@@ -33,6 +33,7 @@ import java.util.GregorianCalendar;
 import java.util.Locale;
 import java.util.SimpleTimeZone;
 import java.io.InputStream;
+import java.io.IOException;
 import java.nio.charset.Charset;
 
 /**
@@ -78,6 +79,14 @@ class StatusEditor implements ISVNEditor
                         long replacesRevision)
     {
         //DEBUG:System.err.println("  [J] StatusEditor.addFile");
+        if (contents != null) {
+            try {
+                contents.close();
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
         checkState();
         receiver.addedFile(relativePath);
     }
@@ -120,6 +129,14 @@ class StatusEditor implements ISVNEditor
                           Map<String, byte[]> properties)
     {
         //DEBUG:System.err.println("  [J] StatusEditor.alterFile");
+        if (contents != null) {
+            try {
+                contents.close();
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
         checkState();
         receiver.modifiedFile(relativePath,
                               (checksum != null && contents != null),