]> source.dussan.org Git - jgit.git/commitdiff
Call unlockPack in finally 55/132255/2
authorMasaya Suzuki <masayasuzuki@google.com>
Sun, 11 Nov 2018 20:27:47 +0000 (12:27 -0800)
committerMasaya Suzuki <masayasuzuki@google.com>
Mon, 12 Nov 2018 01:28:20 +0000 (17:28 -0800)
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>
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

index 35fb0b17a702f8ce3b16198b12e8cf843fd40e4a..d4bf81230ba54b8be236abe1710c8db70eec9cf0 100644 (file)
@@ -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) {