From: Masaya Suzuki Date: Sun, 11 Nov 2018 20:27:47 +0000 (-0800) Subject: Call unlockPack in finally X-Git-Tag: v5.2.0.201811281532-m3~22^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ad379793c7dedc805819fadb8bfc97a4f51c6e29;p=jgit.git 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 --- 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) {