subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1675771 - in /subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl: ISVNEditor.java remote/StatusEditor.java
Date Fri, 24 Apr 2015 04:29:50 GMT
Author: brane
Date: Fri Apr 24 04:29:50 2015
New Revision: 1675771

URL: http://svn.apache.org/r1675771
Log:
Fix a really nifty native memory leak in the JavaHL status editor.

[in subversion/bindings/javahl/src]
* org/apache/subversion/javahl/ISVNEditor.java
  (ISVNEditor.addFile, ISVNEditor.alterFile): Document that the contents
   stream must be closed by the implementation.
* org/apache/subversion/javahl/remote/StatusEditor.java
  (StatusEditor.addFile, StatusEditor.alterFile): Close the contents
   stream, otherwise the Java object will be garbage-collected, but
   the underlying native C++ object will never be destroyed.

Modified:
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java?rev=1675771&r1=1675770&r2=1675771&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java
Fri Apr 24 04:29:50 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/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java?rev=1675771&r1=1675770&r2=1675771&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/StatusEditor.java
Fri Apr 24 04:29:50 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,12 @@ class StatusEditor implements ISVNEditor
                         long replacesRevision)
     {
         //DEBUG:System.err.println("  [J] StatusEditor.addFile");
+        try {
+            contents.close();
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+
         checkState();
         receiver.addedFile(relativePath);
     }
@@ -120,6 +127,12 @@ class StatusEditor implements ISVNEditor
                           Map<String, byte[]> properties)
     {
         //DEBUG:System.err.println("  [J] StatusEditor.alterFile");
+        try {
+            contents.close();
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+
         checkState();
         receiver.modifiedFile(relativePath,
                               (checksum != null && contents != null),



Mime
View raw message