Merge branch '6.0.x'
# Conflicts: # spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java
This commit is contained in:
commit
d868f58e6e
|
|
@ -911,6 +911,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
|||
// static factory method signature or from class inheritance hierarchy...
|
||||
return getTypeForFactoryBeanFromMethod(mbd.getBeanClass(), factoryMethodName);
|
||||
}
|
||||
|
||||
result = getFactoryBeanGeneric(mbd.targetType);
|
||||
if (result.resolve() != null) {
|
||||
return result;
|
||||
}
|
||||
result = getFactoryBeanGeneric(beanType);
|
||||
if (result.resolve() != null) {
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -2032,6 +2032,16 @@ class DefaultListableBeanFactoryTests {
|
|||
assertBeanNamesForType(FactoryBean.class, false, false);
|
||||
}
|
||||
|
||||
@Test // gh-30987
|
||||
void getBeanNamesForTypeWithFactoryBeanDefinedAsTargetType() {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(TestRepositoryFactoryBean.class);
|
||||
beanDefinition.setTargetType(ResolvableType.forClassWithGenerics(TestRepositoryFactoryBean.class,
|
||||
CityRepository.class, Object.class, Object.class));
|
||||
lbf.registerBeanDefinition("factoryBean", beanDefinition);
|
||||
assertBeanNamesForType(TestRepositoryFactoryBean.class, true, false, "&factoryBean");
|
||||
assertBeanNamesForType(CityRepository.class, true, false, "factoryBean");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a dependency on a {@link FactoryBean} can <strong>not</strong>
|
||||
* be autowired <em>by name</em>, as & is an illegal character in
|
||||
|
|
@ -3120,6 +3130,25 @@ class DefaultListableBeanFactoryTests {
|
|||
}
|
||||
|
||||
|
||||
public static class TestRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable>
|
||||
extends RepositoryFactoryBeanSupport<T, S, ID> {
|
||||
|
||||
@Override
|
||||
public T getObject() throws Exception {
|
||||
throw new IllegalArgumentException("Should not be called");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
throw new IllegalArgumentException("Should not be called");
|
||||
}
|
||||
}
|
||||
|
||||
public record City(String name) {}
|
||||
|
||||
public static class CityRepository implements Repository<City, Long> {}
|
||||
|
||||
|
||||
public static class LazyInitFactory implements FactoryBean<Object> {
|
||||
|
||||
public boolean initialized = false;
|
||||
|
|
|
|||
|
|
@ -113,8 +113,9 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
this.baseUrl = "http://localhost:" + this.server.getPort();
|
||||
}
|
||||
|
||||
|
||||
@AfterEach
|
||||
void teardown() throws Exception {
|
||||
void teardown() {
|
||||
try {
|
||||
this.sockJsClient.stop();
|
||||
}
|
||||
|
|
@ -141,6 +142,7 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected abstract Class<?> upgradeStrategyConfigClass();
|
||||
|
||||
protected abstract WebSocketTestServer createWebSocketTestServer();
|
||||
|
|
@ -154,6 +156,7 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
this.sockJsClient.start();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void echoWebSocket() throws Exception {
|
||||
testEcho(100, createWebSocketTransport(), null);
|
||||
|
|
@ -305,8 +308,8 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
try {
|
||||
Thread.sleep(timeToSleep);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new IllegalStateException("Interrupted while waiting for " + description, e);
|
||||
catch (InterruptedException ex) {
|
||||
throw new IllegalStateException("Interrupted while waiting for " + description, ex);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Timed out waiting for " + description);
|
||||
|
|
@ -333,6 +336,7 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestClientHandler extends TextWebSocketHandler {
|
||||
|
||||
private final BlockingQueue<TextMessage> receivedMessages = new LinkedBlockingQueue<>();
|
||||
|
|
@ -341,7 +345,6 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
|
||||
private volatile Throwable transportError;
|
||||
|
||||
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||
this.session = session;
|
||||
|
|
@ -376,6 +379,7 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class EchoHandler extends TextWebSocketHandler {
|
||||
|
||||
@Override
|
||||
|
|
@ -384,21 +388,23 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestServerHandler extends TextWebSocketHandler {
|
||||
|
||||
private WebSocketSession session;
|
||||
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||
public void afterConnectionEstablished(WebSocketSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public WebSocketSession awaitSession(long timeToWait) throws InterruptedException {
|
||||
public WebSocketSession awaitSession(long timeToWait) {
|
||||
awaitEvent(() -> this.session != null, timeToWait, " session");
|
||||
return this.session;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestFilter implements Filter {
|
||||
|
||||
private final Map<String, HttpHeaders> requests = new HashMap<>();
|
||||
|
|
@ -407,7 +413,6 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
|
||||
private final Map<String, Integer> sendErrorMap = new HashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
|
@ -418,18 +423,18 @@ abstract class AbstractSockJsIntegrationTests {
|
|||
this.requests.put(uri, headers);
|
||||
|
||||
for (String suffix : this.sleepDelayMap.keySet()) {
|
||||
if ((httpRequest).getRequestURI().endsWith(suffix)) {
|
||||
if (httpRequest.getRequestURI().endsWith(suffix)) {
|
||||
try {
|
||||
Thread.sleep(this.sleepDelayMap.get(suffix));
|
||||
break;
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
catch (InterruptedException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String suffix : this.sendErrorMap.keySet()) {
|
||||
if ((httpRequest).getRequestURI().endsWith(suffix)) {
|
||||
if (httpRequest.getRequestURI().endsWith(suffix)) {
|
||||
((HttpServletResponse) response).sendError(this.sendErrorMap.get(suffix));
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue