Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-02-12 04:50:54 +0000
committerDavid Pursehouse2016-02-12 04:50:54 +0000
commit83f1f8fc7c46a34d60fe90b683a1fa3a06e27d2e (patch)
treef370529e04a300d6cc7c73dd8c338d81005cdb82
parent3adea9ac7fb916f1cd3aebea5dacac92da749da6 (diff)
downloadjgit-83f1f8fc7c46a34d60fe90b683a1fa3a06e27d2e.tar.gz
jgit-83f1f8fc7c46a34d60fe90b683a1fa3a06e27d2e.tar.xz
jgit-83f1f8fc7c46a34d60fe90b683a1fa3a06e27d2e.zip
RacyGitTests: Open NameConflictTreeWalk in try-with-resource
Change-Id: Ic17b05fd7d056761b352168de97efb607a289276 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java68
1 files changed, 36 insertions, 32 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
index 99d6801f30..aa46d1a2b2 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
@@ -82,38 +82,42 @@ public class RacyGitTests extends RepositoryTestCase {
}
FileTreeIteratorWithTimeControl fileIt = new FileTreeIteratorWithTimeControl(
db, modTimes);
- NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
- tw.addTree(fileIt);
- tw.setRecursive(true);
- FileTreeIterator t;
- long t0 = 0;
- for (int i = 0; i < 10; i++) {
- assertTrue(tw.next());
- t = tw.getTree(0, FileTreeIterator.class);
- if (i == 0)
- t0 = t.getEntryLastModified();
- else
- assertEquals(t0, t.getEntryLastModified());
- }
- long t1 = 0;
- for (int i = 0; i < 10; i++) {
- assertTrue(tw.next());
- t = tw.getTree(0, FileTreeIterator.class);
- if (i == 0) {
- t1 = t.getEntryLastModified();
- assertTrue(t1 > t0);
- } else
- assertEquals(t1, t.getEntryLastModified());
- }
- long t2 = 0;
- for (int i = 0; i < 10; i++) {
- assertTrue(tw.next());
- t = tw.getTree(0, FileTreeIterator.class);
- if (i == 0) {
- t2 = t.getEntryLastModified();
- assertTrue(t2 > t1);
- } else
- assertEquals(t2, t.getEntryLastModified());
+ try (NameConflictTreeWalk tw = new NameConflictTreeWalk(db)) {
+ tw.addTree(fileIt);
+ tw.setRecursive(true);
+ FileTreeIterator t;
+ long t0 = 0;
+ for (int i = 0; i < 10; i++) {
+ assertTrue(tw.next());
+ t = tw.getTree(0, FileTreeIterator.class);
+ if (i == 0) {
+ t0 = t.getEntryLastModified();
+ } else {
+ assertEquals(t0, t.getEntryLastModified());
+ }
+ }
+ long t1 = 0;
+ for (int i = 0; i < 10; i++) {
+ assertTrue(tw.next());
+ t = tw.getTree(0, FileTreeIterator.class);
+ if (i == 0) {
+ t1 = t.getEntryLastModified();
+ assertTrue(t1 > t0);
+ } else {
+ assertEquals(t1, t.getEntryLastModified());
+ }
+ }
+ long t2 = 0;
+ for (int i = 0; i < 10; i++) {
+ assertTrue(tw.next());
+ t = tw.getTree(0, FileTreeIterator.class);
+ if (i == 0) {
+ t2 = t.getEntryLastModified();
+ assertTrue(t2 > t1);
+ } else {
+ assertEquals(t2, t.getEntryLastModified());
+ }
+ }
}
}

Back to the top