Skip to content

Commit

Permalink
Resolve issue with inner configurations and qualifiers. Fixes microna…
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskleeh committed Sep 9, 2019
1 parent e1c4617 commit fa6fdfb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
15 changes: 15 additions & 0 deletions inject-java/src/test/groovy/io/micronaut/aop/named/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.micronaut.aop.named;

import io.micronaut.context.annotation.ConfigurationProperties;

@ConfigurationProperties("config")
public class Config {

public Config(Inner inner) {

}

@ConfigurationProperties("inner")
public static class Inner {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class NamedAopAdviceSpec extends Specification {
context.getBeansOfType(NamedInterface).size() == 3
context.getBeansOfType(NamedInterface).every({ it instanceof Intercepted })



cleanup:
context.close()
}
Expand All @@ -42,8 +40,6 @@ class NamedAopAdviceSpec extends Specification {
context.getBeansOfType(NamedInterface).size() == 2
context.getBeansOfType(NamedInterface).every({ it instanceof Intercepted })



cleanup:
context.close()
}
Expand All @@ -63,4 +59,15 @@ class NamedAopAdviceSpec extends Specification {
cleanup:
context.close()
}

void "test named bean relying on non iterable config"() {
given:
def context = ApplicationContext.run(['other.interfaces.third': 'third'])

expect:
context.getBean(OtherInterface, Qualifiers.byName("third")).doStuff() == 'third'

cleanup:
context.close()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ OtherInterface first() {
OtherInterface second() {
return () -> "second";
}

@EachProperty("other.interfaces")
OtherInterface third(Config config, @Parameter String name) {
return () -> name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,9 @@ private Qualifier resolveQualifier(
qualifier = optional.orElse(null);
}
if (qualifier == null) {
if ((hasMetadata && argument.isAnnotationPresent(Parameter.class)) || innerConfiguration || Qualifier.class == argument.getType()) {
if ((hasMetadata && argument.isAnnotationPresent(Parameter.class)) ||
(innerConfiguration && isIterable) ||
Qualifier.class == argument.getType()) {
final Optional<String> n = resolutionContext.get(NAMED_ATTRIBUTE, String.class);
qualifier = n.map(Qualifiers::byName).orElse(null);
}
Expand Down

0 comments on commit fa6fdfb

Please sign in to comment.