Skip to content

Commit

Permalink
Merge pull request #20295 Fix issue with deadlocking between test tas…
Browse files Browse the repository at this point in the history
…k and dependency resolution
  • Loading branch information
bot-gradle committed Mar 29, 2022
2 parents a41eb19 + 44c20b6 commit 72dedcb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@
import org.gradle.api.internal.tasks.testing.TestStartEvent;
import org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor;
import org.gradle.internal.time.Clock;
import org.gradle.internal.work.WorkerLeaseRegistry;
import org.gradle.internal.work.WorkerLeaseService;

import java.util.Collections;

public class TestMainAction implements Runnable {
private final Runnable detector;
private final TestClassProcessor processor;
Expand Down Expand Up @@ -58,9 +55,7 @@ public void run() {
detector.run();
} finally {
// Release worker lease while waiting for tests to complete
// Do not release any other locks, so that other test tasks from the same project do not start running
WorkerLeaseRegistry.WorkerLease currentWorkerLease = workerLeaseService.getCurrentWorkerLease();
workerLeaseService.withoutLocks(Collections.singletonList(currentWorkerLease), new Runnable() {
workerLeaseService.blocking(new Runnable() {
@Override
public void run() {
processor.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class TestMainActionTest extends Specification {
then:
1* detector.run()
then:
1 * workerLeaseService.currentWorkerLease >> lease
1 * workerLeaseService.withoutLocks([lease], _) >> { l, Runnable runnable -> runnable.run() }
1 * workerLeaseService.blocking(_) >> { Runnable runnable -> runnable.run() }
1 * processor.stop()
then:
1 * timeProvider.getCurrentTime() >> 200L
Expand All @@ -68,8 +67,7 @@ class TestMainActionTest extends Specification {
then:
1 * detector.run() >> { throw failure }
then:
1 * workerLeaseService.currentWorkerLease >> lease
1 * workerLeaseService.withoutLocks([lease], _) >> { l, Runnable runnable -> runnable.run() }
1 * workerLeaseService.blocking(_) >> { Runnable runnable -> runnable.run() }
1 * processor.stop()
then:
1 * resultProcessor.completed(!null, !null)
Expand Down Expand Up @@ -119,8 +117,7 @@ class TestMainActionTest extends Specification {
then:
1 * detector.run()
then:
1 * workerLeaseService.currentWorkerLease >> lease
1 * workerLeaseService.withoutLocks([lease], _) >> { l, Runnable runnable -> runnable.run() }
1 * workerLeaseService.blocking(_) >> { Runnable runnable -> runnable.run() }
1 * processor.stop() >> { throw failure }
then:
1 * resultProcessor.completed(!null, !null)
Expand Down

0 comments on commit 72dedcb

Please sign in to comment.