{"thread":{"id":"19908","subject":"[JGIT PATCH] Fixed the test testUpdateRefLockFailureLocked broken on the Windows platform","startedAt":"2009-06-23T12:01:35Z","lastAt":"2009-06-23T12:01:35Z","messageCount":1,"participants":["Constantine Plotnikov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"116812","messageId":"1245758495-2212-1-git-send-email-constantine.plotnikov@gmail.com","threadId":"19908","inReplyTo":null,"subject":"[JGIT PATCH] Fixed the test testUpdateRefLockFailureLocked broken on the Windows platform","fromName":"Constantine Plotnikov","fromEmail":"constantine.plotnikov@gmail.com","sentAt":"2009-06-23T12:01:35Z","receivedAt":"2009-06-23T12:01:35Z","isPatch":true,"sender":{"key":"constantine.plotnikov@gmail.com","avatar":null},"body":"On Windows the lock is aquired in the test testUpdateRefLockFailureLocked\n(RefUpdateTest) for the file but it never released. This causes test\nfailure during resource cleanup, since locked file could not be deleted\non Windows. This commits adds unlock operation in the finally block,\nso there is no more cleanup problem.\n\nSigned-off-by: Constantine Plotnikov <constantine.plotnikov@gmail.com>\n---\n .../tst/org/spearce/jgit/lib/RefUpdateTest.java    |   16 ++++++++++------\n 1 files changed, 10 insertions(+), 6 deletions(-)\n\ndiff --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\nindex 6b1975a..b14f19a 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java\n@@ -255,12 +255,16 @@ public void testUpdateRefLockFailureLocked() throws IOException {\n \t\tRefUpdate updateRef = db.updateRef(\"refs/heads/master\");\n \t\tupdateRef.setNewObjectId(pid);\n \t\tLockFile lockFile1 = new LockFile(new File(db.getDirectory(),\"refs/heads/master\"));\n-\t\tassertTrue(lockFile1.lock()); // precondition to test\n-\t\tResult update = updateRef.update();\n-\t\tassertEquals(Result.LOCK_FAILURE, update);\n-\t\tassertEquals(opid, db.resolve(\"refs/heads/master\"));\n-\t\tLockFile lockFile2 = new LockFile(new File(db.getDirectory(),\"refs/heads/master\"));\n-\t\tassertFalse(lockFile2.lock()); // was locked, still is\n+\t\ttry {\n+\t\t\tassertTrue(lockFile1.lock()); // precondition to test\n+\t\t\tResult update = updateRef.update();\n+\t\t\tassertEquals(Result.LOCK_FAILURE, update);\n+\t\t\tassertEquals(opid, db.resolve(\"refs/heads/master\"));\n+\t\t\tLockFile lockFile2 = new LockFile(new File(db.getDirectory(),\"refs/heads/master\"));\n+\t\t\tassertFalse(lockFile2.lock()); // was locked, still is\n+\t\t} finally {\n+\t\t\tlockFile1.unlock();\n+\t\t}\n \t}\n \n \t/**\n-- \n1.6.1.2\n"}]}