DORMANTno replies

[JGIT PATCH] Fixed the test testUpdateRefLockFailureLocked broken on the Windows platform

From: Constantine Plotnikov <hidden>
Date: 2016-06-15 22:46:58
Subsystem: the rest · Maintainer: Linus Torvalds

On Windows the lock is aquired in the test testUpdateRefLockFailureLocked
(RefUpdateTest) for the file but it never released. This causes test
failure during resource cleanup, since locked file could not be deleted
on Windows. This commits adds unlock operation in the finally block,
so there is no more cleanup problem.

Signed-off-by: Constantine Plotnikov <redacted>
---
 .../tst/org/spearce/jgit/lib/RefUpdateTest.java    |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
index 6b1975a..b14f19a 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
@@ -255,12 +255,16 @@ public void testUpdateRefLockFailureLocked() throws IOException {
 		RefUpdate updateRef = db.updateRef("refs/heads/master");
 		updateRef.setNewObjectId(pid);
 		LockFile lockFile1 = new LockFile(new File(db.getDirectory(),"refs/heads/master"));
-		assertTrue(lockFile1.lock()); // precondition to test
-		Result update = updateRef.update();
-		assertEquals(Result.LOCK_FAILURE, update);
-		assertEquals(opid, db.resolve("refs/heads/master"));
-		LockFile lockFile2 = new LockFile(new File(db.getDirectory(),"refs/heads/master"));
-		assertFalse(lockFile2.lock()); // was locked, still is
+		try {
+			assertTrue(lockFile1.lock()); // precondition to test
+			Result update = updateRef.update();
+			assertEquals(Result.LOCK_FAILURE, update);
+			assertEquals(opid, db.resolve("refs/heads/master"));
+			LockFile lockFile2 = new LockFile(new File(db.getDirectory(),"refs/heads/master"));
+			assertFalse(lockFile2.lock()); // was locked, still is
+		} finally {
+			lockFile1.unlock();
+		}
 	}
 
 	/**
-- 
1.6.1.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help