The Unified and Autonomous Development Platform
fix: Unable to pull and push (OD-2022)
Robin Shen0ac6db658448
diff --git a/server-core/src/main/java/io/onedev/server/util/concurrent/DefaultWorkExecutor.java b/server-core/src/main/java/io/onedev/server/util/concurrent/DefaultWorkExecutor.javaindex 4a632a6bb5..baf8c8d52c 100644--- a/server-core/src/main/java/io/onedev/server/util/concurrent/DefaultWorkExecutor.java+++ b/server-core/src/main/java/io/onedev/server/util/concurrent/DefaultWorkExecutor.java@@ -90,11 +90,7 @@ public class DefaultWorkExecutor implements WorkExecutor {return call(groupId, callable);} else {WorkFuture<T> future = new WorkFuture<T>(groupId, callable);- Collection<WorkFuture<?>> waitingsOfGroup = waitings.get(groupId);- if (waitingsOfGroup == null) {- waitingsOfGroup = new ArrayList<>();- waitings.put(groupId, waitingsOfGroup);- }+ var waitingsOfGroup = waitings.computeIfAbsent(groupId, k -> new ArrayList<>());waitingsOfGroup.add(future);check();return future;@@ -121,10 +117,14 @@ public class DefaultWorkExecutor implements WorkExecutor {return runningFuture.cancel(mayInterruptIfRunning);} else {Collection<WorkFuture<?>> waitingsOfGroup = waitings.get(groupId);- if (waitingsOfGroup != null)- return waitingsOfGroup.remove(this);- else+ if (waitingsOfGroup != null) {+ var cancelled = waitingsOfGroup.remove(this);+ if (waitingsOfGroup.isEmpty())+ waitings.remove(groupId);+ return cancelled;+ } else {return false;+ }}}}