[jboss-jira] [JBoss JIRA] (WFLY-3632) @Inject broken for parameterized interfaces
Alexander Langer (JIRA)
issues at jboss.org
Tue Jul 15 16:38:30 EDT 2014
[ https://issues.jboss.org/browse/WFLY-3632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexander Langer updated WFLY-3632:
-----------------------------------
Description:
@Inject is broken on Wildfly 8.1.0 Final when the interface to be injected is parameterized with a type that extends another type. Example code:
{code}
public interface Foo<T extends Serializable> { } // will fail
public class FooBean implements Foo { }
public interface Bar<T> { } // will work
public class BarBean implements Bar { }
@Singleton
@Startup
public class TestSingleton {
@Inject
private Instance<Foo> foo;
@Inject
private Instance<Bar> bar;
@PostConstruct
public void init() {
System.out.println("##### foo is unsatisfied = " + foo.isUnsatisfied());
for (Foo f : foo)
System.out.println("foo is: " + f.getClass().getCanonicalName());
System.out.println("##### bar is unsatisfied = " + bar.isUnsatisfied());
for (Bar b : bar)
System.out.println("bar is: " + b.getClass().getCanonicalName());
}
}
{code}
output:
{code}
22:30:25,904 INFO [stdout] (ServerService Thread Pool -- 50) ##### foo is unsatisfied = true
22:30:25,905 INFO [stdout] (ServerService Thread Pool -- 50) ##### bar is unsatisfied = false
{code}
The same code works on JBoss AS 7.1.1, so something must have changed for Wildfly.
The attached small example project can be used to reproduce the error.
was:
@Inject is broken on Wildfly 8.1.0 Final when the interface to be injected is parameterized with a type that extends another type. Example code:
{code}
public interface Foo<T extends Serializable> { } // will fail
public class FooBean implements Foo { }
public interface Bar<T> { } // will work
public class BarBean implements Bar { }
@Singleton
@Startup
public class TestSingleton {
@Inject
private Instance<Foo> foo;
@Inject
private Instance<Bar> bar;
@PostConstruct
public void init() {
System.out.println("##### foo is unsatisfied = " + foo.isUnsatisfied());
for (Foo f : foo)
System.out.println("foo is: " + f.getClass().getCanonicalName());
System.out.println("##### bar is unsatisfied = " + bar.isUnsatisfied());
for (Bar b : bar)
System.out.println("bar is: " + b.getClass().getCanonicalName());
}
}
{code}
output:
{{
22:30:25,904 INFO [stdout] (ServerService Thread Pool -- 50) ##### foo is unsatisfied = true
22:30:25,905 INFO [stdout] (ServerService Thread Pool -- 50) ##### bar is unsatisfied = false
}}
The same code works on JBoss AS 7.1.1, so something must have changed for Wildfly.
The attached small example project can be used to reproduce the error.
> @Inject broken for parameterized interfaces
> -------------------------------------------
>
> Key: WFLY-3632
> URL: https://issues.jboss.org/browse/WFLY-3632
> Project: WildFly
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Environment: Wildfly 8.1.0Final (tested on MacOS X 10.9.3)
> Reporter: Alexander Langer
> Assignee: Jason Greene
> Attachments: CDIMultiModuleTest.zip
>
>
> @Inject is broken on Wildfly 8.1.0 Final when the interface to be injected is parameterized with a type that extends another type. Example code:
> {code}
> public interface Foo<T extends Serializable> { } // will fail
> public class FooBean implements Foo { }
> public interface Bar<T> { } // will work
> public class BarBean implements Bar { }
> @Singleton
> @Startup
> public class TestSingleton {
> @Inject
> private Instance<Foo> foo;
> @Inject
> private Instance<Bar> bar;
> @PostConstruct
> public void init() {
> System.out.println("##### foo is unsatisfied = " + foo.isUnsatisfied());
> for (Foo f : foo)
> System.out.println("foo is: " + f.getClass().getCanonicalName());
> System.out.println("##### bar is unsatisfied = " + bar.isUnsatisfied());
> for (Bar b : bar)
> System.out.println("bar is: " + b.getClass().getCanonicalName());
> }
> }
> {code}
> output:
> {code}
> 22:30:25,904 INFO [stdout] (ServerService Thread Pool -- 50) ##### foo is unsatisfied = true
> 22:30:25,905 INFO [stdout] (ServerService Thread Pool -- 50) ##### bar is unsatisfied = false
> {code}
> The same code works on JBoss AS 7.1.1, so something must have changed for Wildfly.
> The attached small example project can be used to reproduce the error.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
More information about the jboss-jira
mailing list