From ad379793c7dedc805819fadb8bfc97a4f51c6e29 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki Date: Sun, 11 Nov 2018 12:27:47 -0800 Subject: [PATCH] Call unlockPack in finally The lock is obtained in receivePackAndCheckConnectivity. It seems to me the structure that requres the caller to unlock the lock is wrong, but at least by calling in finally ensures it is called even if an exception is thrown. Change-Id: I123841b017baf5acffe0064d1004ef11a0a5e6c2 Signed-off-by: Masaya Suzuki --- .../eclipse/jgit/transport/ReceivePack.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java index 35fb0b17a7..d4bf81230b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -269,20 +269,26 @@ public class ReceivePack extends BaseReceivePack { } } - if (unpackError == null) { - boolean atomic = isCapabilityEnabled(CAPABILITY_ATOMIC); - setAtomic(atomic); + try { + if (unpackError == null) { + boolean atomic = isCapabilityEnabled(CAPABILITY_ATOMIC); + setAtomic(atomic); - validateCommands(); - if (atomic && anyRejects()) - failPendingCommands(); + validateCommands(); + if (atomic && anyRejects()) { + failPendingCommands(); + } - preReceive.onPreReceive(this, filterCommands(Result.NOT_ATTEMPTED)); - if (atomic && anyRejects()) - failPendingCommands(); - executeCommands(); + preReceive.onPreReceive( + this, filterCommands(Result.NOT_ATTEMPTED)); + if (atomic && anyRejects()) { + failPendingCommands(); + } + executeCommands(); + } + } finally { + unlockPack(); } - unlockPack(); if (reportStatus) { if (echoCommandFailures && msgOut != null) { -- 2.39.5