Skip to content

Commit 14a5a04

Browse files
authored
fix factory method list soft dependencies (#844)
fixes an issue where factory methods threw compilation exceptions for empty lists
1 parent bd85f19 commit 14a5a04

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

blackbox-test-inject/src/main/java/org/example/myapp/ListFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
public class ListFactory {
1313

1414
@Bean
15-
List<String> test() {
15+
List<String> test(List<Cloneable> emptyList) {
1616
return List.of("test1", "test2");
1717
}
1818

inject-generator/src/main/java/io/avaje/inject/generator/MethodReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ MetaData createMeta() {
204204

205205
for (final MethodParam param : params) {
206206
var dep = Util.addQualifierSuffix(param.named, Util.trimWildcard(param.paramType));
207-
dependsOn.add(dep);
207+
dependsOn.add(param.utilType.isCollection() ? Constants.SOFT_DEPENDENCY + dep : dep);
208208
}
209209
metaData.setDependsOn(dependsOn);
210210
metaData.setProvides(

inject-generator/src/test/java/io/avaje/inject/generator/models/valid/ListFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public class ListFactory {
1010

1111
@Bean(initMethod = "postConstruct")
12-
List<Something> userId() {
12+
List<Something> userId(List<Short> shortyList) {
1313
return List.of(new Something());
1414
}
1515

0 commit comments

Comments
 (0)