Browse Source

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>
stable-4.1
Hugo Arès 10 years ago
parent
commit
27128b3e01
  1. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java
  2. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/UnpackedObjectTest.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
  5. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
  6. 4
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java

@ -123,7 +123,7 @@ public class PackFileTest extends LocalDiskRepositoryTestCase {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
if (wc != null) if (wc != null)
wc.release(); wc.close();
new WindowCacheConfig().install(); new WindowCacheConfig().install();
super.tearDown(); super.tearDown();
} }

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/UnpackedObjectTest.java

@ -108,7 +108,7 @@ public class UnpackedObjectTest extends LocalDiskRepositoryTestCase {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
if (wc != null) if (wc != null)
wc.release(); wc.close();
new WindowCacheConfig().install(); new WindowCacheConfig().install();
super.tearDown(); super.tearDown();
} }

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInputStream.java

@ -80,6 +80,6 @@ class PackInputStream extends InputStream {
@Override @Override
public void close() { public void close() {
wc.release(); wc.close();
} }
} }

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java

@ -95,7 +95,7 @@ public class UnpackedObject {
try { try {
return open(new ByteArrayInputStream(raw), null, id, wc); return open(new ByteArrayInputStream(raw), null, id, wc);
} finally { } finally {
wc.release(); wc.close();
} }
} }

3
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. */ /** Release the current window cursor. */
public void release() { @Override
public void close() {
window = null; window = null;
baseCache = null; baseCache = null;
try { try {

4
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java

@ -430,7 +430,5 @@ public abstract class ObjectReader implements AutoCloseable {
* @since 4.0 * @since 4.0
*/ */
@Override @Override
public void close() { public abstract void close();
// Do nothing.
}
} }

Loading…
Cancel
Save