diff options
author | Masaya Suzuki <masayasuzuki@google.com> | 2018-11-11 12:27:47 -0800 |
---|---|---|
committer | Masaya Suzuki <masayasuzuki@google.com> | 2018-11-11 17:28:20 -0800 |
commit | ad379793c7dedc805819fadb8bfc97a4f51c6e29 (patch) | |
tree | 36d261d224bb1436e2f47962a92bb6b57f472a8d | |
parent | 54dd1d112a46a2b5a76fcdc1776c21fb110e497f (diff) | |
download | jgit-ad379793c7dedc805819fadb8bfc97a4f51c6e29.tar.gz jgit-ad379793c7dedc805819fadb8bfc97a4f51c6e29.zip |
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 <masayasuzuki@google.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java | 28 |
1 files 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) { |