From 705f0ff263872efe91fd37d9600a114672d424df Mon Sep 17 00:00:00 2001 From: Julien Kronegg Date: Thu, 1 Jun 2023 10:37:03 +0200 Subject: [PATCH] [Pico] Fixed UnsatisfiableDependencyException with Component dependencies (#2764) Co-authored-by: Julien Kronegg --- CHANGELOG.md | 1 + .../main/java/io/cucumber/picocontainer/PicoFactory.java | 2 +- .../StepDefinitionsWithTransitiveDependencies.java | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6c898d2f3..0cfc8b36b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Core] Fixed `cucumber.publish.enabled=false` ([#2747](https://github.com/cucumber/cucumber-jvm/pull/2747) M.P. Korstanje) - [JUnit Platform Engine] Fixed `cucumber.publish.enabled=false` ([#2747](https://github.com/cucumber/cucumber-jvm/pull/2747) M.P. Korstanje) - [Java] Fixed duplicate step definition for classes with interfaces ([#2757](https://github.com/cucumber/cucumber-jvm/issues/2757) Julien Kronegg) +- [Pico] Fixed unsatisfiable dependency with disposables ([#2762](https://github.com/cucumber/cucumber-jvm/issues/2762) Julien Kronegg) ## [7.12.0] - 2023-04-29 ### Added diff --git a/cucumber-picocontainer/src/main/java/io/cucumber/picocontainer/PicoFactory.java b/cucumber-picocontainer/src/main/java/io/cucumber/picocontainer/PicoFactory.java index 641e49b0ac..c5e1e6fa2a 100644 --- a/cucumber-picocontainer/src/main/java/io/cucumber/picocontainer/PicoFactory.java +++ b/cucumber-picocontainer/src/main/java/io/cucumber/picocontainer/PicoFactory.java @@ -43,8 +43,8 @@ public void stop() { @Override public boolean addClass(Class clazz) { if (isInstantiable(clazz) && classes.add(clazz)) { - pico.addComponent(clazz); addConstructorDependencies(clazz); + pico.addComponent(clazz); } return true; } diff --git a/cucumber-picocontainer/src/test/java/io/cucumber/picocontainer/StepDefinitionsWithTransitiveDependencies.java b/cucumber-picocontainer/src/test/java/io/cucumber/picocontainer/StepDefinitionsWithTransitiveDependencies.java index 83d967df1d..8afd5d4b12 100644 --- a/cucumber-picocontainer/src/test/java/io/cucumber/picocontainer/StepDefinitionsWithTransitiveDependencies.java +++ b/cucumber-picocontainer/src/test/java/io/cucumber/picocontainer/StepDefinitionsWithTransitiveDependencies.java @@ -1,5 +1,7 @@ package io.cucumber.picocontainer; +import org.picocontainer.Disposable; + public class StepDefinitionsWithTransitiveDependencies { final FirstDependency firstDependency; @@ -8,12 +10,16 @@ public StepDefinitionsWithTransitiveDependencies(FirstDependency firstDependency this.firstDependency = firstDependency; } - public static class FirstDependency { + public static class FirstDependency implements Disposable { final SecondDependency secondDependency; public FirstDependency(SecondDependency secondDependency) { this.secondDependency = secondDependency; } + + @Override + public void dispose() { + } } public static class SecondDependency {