Browse Source

PackFileTest: Open ObjectInserter.Formatter in try-with-resource

Change-Id: I9c56b5efdb9c13b929073a786092a707fca21281
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
5c84145fd0
  1. 9
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileTest.java

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

@ -191,7 +191,7 @@ public class PackFileTest extends LocalDiskRepositoryTestCase {
@Test
public void testDelta_SmallObjectChain() throws Exception {
ObjectInserter.Formatter fmt = new ObjectInserter.Formatter();
try (ObjectInserter.Formatter fmt = new ObjectInserter.Formatter()) {
byte[] data0 = new byte[512];
Arrays.fill(data0, (byte) 0xf3);
ObjectId id0 = fmt.idFor(Constants.OBJ_BLOB, data0);
@ -247,10 +247,11 @@ public class PackFileTest extends LocalDiskRepositoryTestCase {
assertEquals("stream at EOF", -1, in.read());
in.close();
}
}
@Test
public void testDelta_FailsOver2GiB() throws Exception {
ObjectInserter.Formatter fmt = new ObjectInserter.Formatter();
try (ObjectInserter.Formatter fmt = new ObjectInserter.Formatter()) {
byte[] base = new byte[] { 'a' };
ObjectId idA = fmt.idFor(Constants.OBJ_BLOB, base);
ObjectId idB = fmt.idFor(Constants.OBJ_BLOB, new byte[] { 'b' });
@ -274,7 +275,8 @@ public class PackFileTest extends LocalDiskRepositoryTestCase {
deflate(pack, delta);
byte[] footer = digest(pack);
File dir = new File(repo.getObjectDatabase().getDirectory(), "pack");
File dir = new File(repo.getObjectDatabase().getDirectory(),
"pack");
File packName = new File(dir, idA.name() + ".pack");
File idxName = new File(dir, idA.name() + ".idx");
@ -306,6 +308,7 @@ public class PackFileTest extends LocalDiskRepositoryTestCase {
packFile.close();
}
}
}
private static byte[] clone(int first, byte[] base) {
byte[] r = new byte[base.length];

Loading…
Cancel
Save