]> source.dussan.org Git - jgit.git/commitdiff
Fix WindowCursor memory leak. 04/48904/1
authorHugo Arès <hugo.ares@ericsson.com>
Thu, 28 May 2015 18:21:03 +0000 (14:21 -0400)
committerHugo Arès <hugo.ares@ericsson.com>
Thu, 28 May 2015 19:14:25 +0000 (15:14 -0400)
ObjectReader release method was replaced by close method but
WindowCursor was still implementing release method.

To prevent the same mistake again, make ObjectReader close method
abstract to force sub classes to implement it.

Change-Id: I50d0d1d19a26e306fd0dba77b246a95a44fd6584
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/UnpackedObjectTest.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java

index 05055644ece047401e10143abc5b19fad58aa74a..cb80768e51ca82c0935850a02064bcd9b64551cf 100644 (file)
@@ -123,7 +123,7 @@ public class PackFileTest extends LocalDiskRepositoryTestCase {
        @After
        public void tearDown() throws Exception {
                if (wc != null)
-                       wc.release();
+                       wc.close();
                new WindowCacheConfig().install();
                super.tearDown();
        }
index 10d2b6b52678dbadf34ffab8637466a474882543..8c8c6c6d0ca93cd2e5c2fd521952a41b872ff2ae 100644 (file)
@@ -108,7 +108,7 @@ public class UnpackedObjectTest extends LocalDiskRepositoryTestCase {
        @After
        public void tearDown() throws Exception {
                if (wc != null)
-                       wc.release();
+                       wc.close();
                new WindowCacheConfig().install();
                super.tearDown();
        }
index 9cb834957aace0d5a8791899a368513fc56c53f2..154809bad8e01e469e48a9d6646859422f7aaffa 100644 (file)
@@ -80,6 +80,6 @@ class PackInputStream extends InputStream {
 
        @Override
        public void close() {
-               wc.release();
+               wc.close();
        }
 }
\ No newline at end of file
index cb95a7656355239d762cb95897846c8921ecde45..cb7d91259304c1176967092ea0f0f0080e9db936 100644 (file)
@@ -95,7 +95,7 @@ public class UnpackedObject {
                try {
                        return open(new ByteArrayInputStream(raw), null, id, wc);
                } finally {
-                       wc.release();
+                       wc.close();
                }
        }
 
index 3e6cb583584c9ea1cbf63350c15502e9c01b4e1a..a555e10d4735e0b7ad5271448aacfc83f3fd26ea 100644 (file)
@@ -330,7 +330,8 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
        }
 
        /** Release the current window cursor. */
-       public void release() {
+       @Override
+       public void close() {
                window = null;
                baseCache = null;
                try {
index 4c9af85fa8b0a8b82c524ddf8ae5f1ebc0e324ae..77cfb038cc288a65da829307d025f15a21f6b149 100644 (file)
@@ -430,7 +430,5 @@ public abstract class ObjectReader implements AutoCloseable {
         * @since 4.0
         */
        @Override
-       public void close() {
-               // Do nothing.
-       }
+       public abstract void close();
 }