aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJukka Jokiniva <jukka.jokiniva@qt.io>2020-08-10 09:22:12 +0300
committerJukka Jokiniva <jukka.jokiniva@qt.io>2020-08-10 12:43:06 +0000
commit7580f88b65ab62979a3888d01b05a28a297918ba (patch)
tree4d718a8ad4c6e9da1c4e1e9ae29a56861b018bfe
parentc0b9476bf18ef955f0a3b81bd9d6f4fc5f02f4aa (diff)
Block parallel processing of stage requestsv3.0-based
Change-Id: I39356629df4f82e5f813c457fc69079a003473cf Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java
index cb7084d..e28063f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java
@@ -46,6 +46,7 @@ import com.google.inject.Singleton;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Config;
@@ -71,6 +72,7 @@ public class QtStage
}
}
+ private final ReentrantLock stageLock = new ReentrantLock();
private final GitRepositoryManager repoManager;
private final PermissionBackend permissionBackend;
private final ChangeData.Factory changeDataFactory;
@@ -123,25 +125,32 @@ public class QtStage
throws RestApiException, RepositoryNotFoundException, IOException, PermissionBackendException,
UpdateException, ConfigInvalidException {
- logger.atInfo().log("qtcodereview: stage %s", rsrc.getChange().toString());
+ Output output;
+ logger.atInfo().log("qtcodereview: stage request reveived for %s", rsrc.getChange().toString());
- IdentifiedUser submitter = rsrc.getUser().asIdentifiedUser();
- change = rsrc.getChange();
- projectKey = rsrc.getProject();
- destBranchKey = change.getDest();
- stagingBranchKey = QtUtil.getStagingBranch(destBranchKey);
+ stageLock.lock(); // block processing of parallel stage requests
+ try {
+ IdentifiedUser submitter = rsrc.getUser().asIdentifiedUser();
+ change = rsrc.getChange();
+ projectKey = rsrc.getProject();
+ destBranchKey = change.getDest();
+ stagingBranchKey = QtUtil.getStagingBranch(destBranchKey);
- rsrc.permissions().check(ChangePermission.QT_STAGE);
+ rsrc.permissions().check(ChangePermission.QT_STAGE);
+ projectCache.checkedGet(rsrc.getProject()).checkStatePermitsWrite();
- projectCache.checkedGet(rsrc.getProject()).checkStatePermitsWrite();
+ output = new Output(changeToStaging(rsrc, submitter, input));
+ } finally {
+ stageLock.unlock();
+ }
- return new Output(changeToStaging(rsrc, submitter, input));
+ return output;
}
private Change changeToStaging(RevisionResource rsrc, IdentifiedUser submitter, SubmitInput input)
throws RestApiException, IOException, UpdateException, ConfigInvalidException,
PermissionBackendException {
- logger.atInfo().log("qtcodereview: changeToStaging starts");
+ logger.atInfo().log("qtcodereview: changeToStaging starts for %s", change.toString());
if (change.getStatus() != Change.Status.NEW) {
logger.atSevere().log(