-
Couldn't load subscription status.
- Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Oliver Drotbohm opened SPR-16179 and commented
The following test fails:
package example;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SpringInjectionTest {
@Configuration
static class Config {
@Bean
PageAssembler<?> assembler() {
return new PageAssembler<>();
}
}
@Autowired(required = false) Assembler<SomeOtherType> assembler;
@Test
public void testname() {
assertThat(assembler, is(nullValue()));
}
interface Assembler<T> {}
static class PageAssembler<T> implements Assembler<Page<T>> {}
interface Page<T> {}
interface SomeOtherType {}
}Spring injects the configured bean instance here despite the fact that the generic declarations clearly don't match as Page<T> is not compatible with the requested SomeOtherType.
Affects: 4.3.12, 5.0.1
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug