Skip to content

Commit 8f0ad36

Browse files
committed
Use the correct instances to destroy CDI beans obtained from Instances.
1 parent fff02d3 commit 8f0ad36

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

cdi/instance-qualifiers/src/test/java/org/javaee7/cdi/instance/AnyGreetingTest.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ public void test() throws Exception {
4949
assertTrue(instance.isAmbiguous());
5050

5151
// use Instance<T>#select()
52-
Greeting businessBean = instance.select(new AnnotationLiteral<Business>() {}).get();
52+
Instance<Greeting> businessInstance = instance.select(new AnnotationLiteral<Business>() {});
53+
Greeting businessBean = businessInstance.get();
5354
assertThat(businessBean, instanceOf(FormalGreeting.class));
54-
instance.destroy(businessBean);
55+
businessInstance.destroy(businessBean);
5556

56-
Greeting defaultBean = instance.select(new AnnotationLiteral<Default>() {}).get();
57+
Instance<Greeting> defaultInstance = instance.select(new AnnotationLiteral<Default>() {});
58+
Greeting defaultBean = defaultInstance.get();
5759
assertThat(defaultBean, instanceOf(SimpleGreeting.class));
58-
instance.destroy(defaultBean);
60+
defaultInstance.destroy(defaultBean);
5961
}
6062
}
6163

cdi/instance-qualifiers/src/test/java/org/javaee7/cdi/instance/GreetingTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ public void test() throws Exception {
5454
instance.destroy(bean);
5555

5656
// use Instance<T>#select()
57-
Greeting anotherBean = instance.select(new AnnotationLiteral<Default>() {}).get();
57+
Instance<Greeting> anotherInstance = instance.select(new AnnotationLiteral<Default>() {
58+
});
59+
Greeting anotherBean = anotherInstance.get();
5860
assertThat(anotherBean, instanceOf(SimpleGreeting.class));
59-
instance.destroy(anotherBean);
61+
anotherInstance.destroy(anotherBean);
6062
}
6163
}
6264

0 commit comments

Comments
 (0)