summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasaya Suzuki <masayasuzuki@google.com>2018-11-11 12:27:47 -0800
committerMasaya Suzuki <masayasuzuki@google.com>2018-11-11 17:28:20 -0800
commitad379793c7dedc805819fadb8bfc97a4f51c6e29 (patch)
tree36d261d224bb1436e2f47962a92bb6b57f472a8d
parent54dd1d112a46a2b5a76fcdc1776c21fb110e497f (diff)
downloadjgit-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.java28
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) {