Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
// Only process singleton beans, not scoped beans
continue;
}
var foundAnnotations = this.scan(AutoProxyUtils.determineTargetClass(beanFactory, beanName));
Class<?> beanClass = AutoProxyUtils.determineTargetClass(beanFactory, beanName);
if (beanClass == null) {
// If we cannot determine the bean class, we cannot scan it before
// it is really resolved. This is very likely an infrastructure-level
// bean, not a "service" type, skip it entirely.
continue;
}
var foundAnnotations = this.scan(beanClass);
if (!foundAnnotations.isEmpty()) {
this.allAnnotatedBeans.add(beanName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.InstanceOfAssertFactories.type;

Expand Down Expand Up @@ -340,6 +341,16 @@ void supportsProxiedClass() {
assertThat(registry.getCapabilities("client-1").elicitation()).isNotNull();
}

@Test
void skipsUnknownBeanClass() {
var registry = new ClientMcpAsyncHandlersRegistry();
var beanFactory = new DefaultListableBeanFactory();
beanFactory.registerBeanDefinition("myConfig",
BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition());

assertThatNoException().isThrownBy(() -> registry.postProcessBeanFactory(beanFactory));
}

static class ClientCapabilitiesConfiguration {

@McpElicitation(clients = { "client-1", "client-2" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.InstanceOfAssertFactories.type;

Expand Down Expand Up @@ -332,6 +333,16 @@ void supportsProxiedClass() {
assertThat(registry.getCapabilities("client-1").elicitation()).isNotNull();
}

@Test
void skipsUnknownBeanClass() {
var registry = new ClientMcpAsyncHandlersRegistry();
var beanFactory = new DefaultListableBeanFactory();
beanFactory.registerBeanDefinition("myConfig",
BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition());

assertThatNoException().isThrownBy(() -> registry.postProcessBeanFactory(beanFactory));
}

static class ClientCapabilitiesConfiguration {

@McpElicitation(clients = { "client-1", "client-2" })
Expand Down