Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2018-03-06 23:14:08 +0000
committerDavid Pursehouse2018-03-06 23:14:08 +0000
commit7b57ce518693ba9cf2899100e8dad892571d500e (patch)
treeb8ea97d0ae2d86f6c7fc2ab8af61d9e089e7bc28 /org.eclipse.jgit.test/tst
parentb5115f6897a70329abe81cad87098f467c6e09fd (diff)
downloadjgit-7b57ce518693ba9cf2899100e8dad892571d500e.tar.gz
jgit-7b57ce518693ba9cf2899100e8dad892571d500e.tar.xz
jgit-7b57ce518693ba9cf2899100e8dad892571d500e.zip
HugeFileTest: Open RandomAccessFile in try-with-resource
Change-Id: Iecb9a7348b40c91fa45c051c2a9c4eb47e4bdeca Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java46
1 files changed, 23 insertions, 23 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java
index 4208f4d8e3..6c3504aa48 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/HugeFileTest.java
@@ -87,9 +87,9 @@ public class HugeFileTest extends RepositoryTestCase {
public void testAddHugeFile() throws Exception {
measure("Commencing test");
File file = new File(db.getWorkTree(), "a.txt");
- RandomAccessFile rf = new RandomAccessFile(file, "rw");
- rf.setLength(4429185024L);
- rf.close();
+ try (RandomAccessFile rf = new RandomAccessFile(file, "rw")) {
+ rf.setLength(4429185024L);
+ }
measure("Created file");
git.add().addFilepattern("a.txt").call();
@@ -109,9 +109,9 @@ public class HugeFileTest extends RepositoryTestCase {
assertEquals(0, status.getUntracked().size());
// Does not change anything, but modified timestamp
- rf = new RandomAccessFile(file, "rw");
- rf.write(0);
- rf.close();
+ try (RandomAccessFile rf = new RandomAccessFile(file, "rw")) {
+ rf.write(0);
+ }
status = git.status().call();
measure("Status after non-modifying update");
@@ -125,9 +125,9 @@ public class HugeFileTest extends RepositoryTestCase {
assertEquals(0, status.getUntracked().size());
// Change something
- rf = new RandomAccessFile(file, "rw");
- rf.write('a');
- rf.close();
+ try (RandomAccessFile rf = new RandomAccessFile(file, "rw")) {
+ rf.write('a');
+ }
status = git.status().call();
measure("Status after modifying update");
@@ -141,10 +141,10 @@ public class HugeFileTest extends RepositoryTestCase {
assertEquals(0, status.getUntracked().size());
// Truncate mod 4G and re-establish equality
- rf = new RandomAccessFile(file, "rw");
- rf.setLength(134217728L);
- rf.write(0);
- rf.close();
+ try (RandomAccessFile rf = new RandomAccessFile(file, "rw")) {
+ rf.setLength(134217728L);
+ rf.write(0);
+ }
status = git.status().call();
measure("Status after truncating update");
@@ -158,9 +158,9 @@ public class HugeFileTest extends RepositoryTestCase {
assertEquals(0, status.getUntracked().size());
// Change something
- rf = new RandomAccessFile(file, "rw");
- rf.write('a');
- rf.close();
+ try (RandomAccessFile rf = new RandomAccessFile(file, "rw")) {
+ rf.write('a');
+ }
status = git.status().call();
measure("Status after modifying and truncating update");
@@ -174,10 +174,10 @@ public class HugeFileTest extends RepositoryTestCase {
assertEquals(0, status.getUntracked().size());
// Truncate to entry length becomes negative int
- rf = new RandomAccessFile(file, "rw");
- rf.setLength(3429185024L);
- rf.write(0);
- rf.close();
+ try (RandomAccessFile rf = new RandomAccessFile(file, "rw")) {
+ rf.setLength(3429185024L);
+ rf.write(0);
+ }
git.add().addFilepattern("a.txt").call();
measure("Added truncated file");
@@ -197,9 +197,9 @@ public class HugeFileTest extends RepositoryTestCase {
assertEquals(0, status.getUntracked().size());
// Change something
- rf = new RandomAccessFile(file, "rw");
- rf.write('a');
- rf.close();
+ try (RandomAccessFile rf = new RandomAccessFile(file, "rw")) {
+ rf.write('a');
+ }
status = git.status().call();
measure("Status after modifying and truncating update");

Back to the top