summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Arès <hugo.ares@ericsson.com>2015-05-28 14:21:03 -0400
committerHugo Arès <hugo.ares@ericsson.com>2015-05-28 15:14:25 -0400
commit27128b3e01a9c97f1d2549ded0d381f469f0aee8 (patch)
tree380fd9c52320823e4dee7b7aaf9f3cab10efda3b
parentebfd62433a58d23af221adfdffed56d9274f4268 (diff)
downloadjgit-27128b3e01a9c97f1d2549ded0d381f469f0aee8.tar.gz
jgit-27128b3e01a9c97f1d2549ded0d381f469f0aee8.zip
Fix WindowCursor memory leak.
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>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/UnpackedObjectTest.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java4
6 files changed, 7 insertions, 8 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java
index 05055644ec..cb80768e51 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java
@@ -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();
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/UnpackedObjectTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/UnpackedObjectTest.java
index 10d2b6b526..8c8c6c6d0c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/UnpackedObjectTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/UnpackedObjectTest.java
@@ -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();
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
index 9cb834957a..154809bad8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
@@ -80,6 +80,6 @@ class PackInputStream extends InputStream {
@Override
public void close() {
- wc.release();
+ wc.close();
}
} \ No newline at end of file
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
index cb95a76563..cb7d912593 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
@@ -95,7 +95,7 @@ public class UnpackedObject {
try {
return open(new ByteArrayInputStream(raw), null, id, wc);
} finally {
- wc.release();
+ wc.close();
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
index 3e6cb58358..a555e10d47 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
@@ -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 {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
index 4c9af85fa8..77cfb038cc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
@@ -430,7 +430,5 @@ public abstract class ObjectReader implements AutoCloseable {
* @since 4.0
*/
@Override
- public void close() {
- // Do nothing.
- }
+ public abstract void close();
}