Skip to content

Commit 85b2c7d

Browse files
committed
AbstractAutowireCapableBeanFactory's getTypeForFactoryBean considers FactoryBean<Object> declarations as non-indicative (just like raw declarations)
Issue: SPR-11842
1 parent de1a41a commit 85b2c7d

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
759759
}
760760
}
761761
});
762-
if (objectType.value != null) {
762+
if (objectType.value != null && !Object.class.equals(objectType.value)) {
763763
return objectType.value;
764764
}
765765
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright 2002-2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.remoting.httpinvoker;
18+
19+
import org.junit.Test;
20+
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.context.ApplicationContext;
23+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
24+
import org.springframework.context.annotation.Bean;
25+
import org.springframework.context.annotation.ComponentScan;
26+
import org.springframework.context.annotation.Configuration;
27+
import org.springframework.stereotype.Component;
28+
29+
import static org.junit.Assert.*;
30+
31+
/**
32+
*
33+
* @author Stephane Nicoll
34+
*/
35+
public class HttpInvokerFactoryBeanIntegrationTests {
36+
37+
@Test
38+
public void foo() {
39+
ApplicationContext context = new AnnotationConfigApplicationContext(InvokerAutowiringConfig.class);
40+
MyBean myBean = context.getBean(MyBean.class);
41+
assertSame(context.getBean("myService"), myBean.myService);
42+
}
43+
44+
45+
public interface MyService {
46+
}
47+
48+
49+
@Component
50+
public static class MyBean {
51+
52+
@Autowired
53+
private MyService myService;
54+
}
55+
56+
57+
@Configuration
58+
@ComponentScan
59+
public static class InvokerAutowiringConfig {
60+
61+
@Bean
62+
public HttpInvokerProxyFactoryBean myService() {
63+
HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean();
64+
factory.setServiceUrl("/svc/dummy");
65+
factory.setServiceInterface(MyService.class);
66+
return factory;
67+
}
68+
}
69+
70+
}

0 commit comments

Comments
 (0)