Skip to content

EndpointWebExtension fails when the user declares their own implementation of spring provided Endpoint #13082

@ptahchiev

Description

@ptahchiev

As discussed on the gitter channel I extend the CachesEndpoint with my own functionality:

public class MyCachesEndpoint extends CachesEndpoint {

and then I register it like this:

    @Bean(name = MyCachesEndpoint.NAME)
    @ConditionalOnEnabledEndpoint
    public CachesEndpoint defaultMyCachesEndpoint(ObjectProvider<Map<String, CacheManager>> cacheManagers) {
        return new MyCachesEndpoint(cacheManagers.getIfAvailable(LinkedHashMap::new));
    }

but then when I start the server I get:

Caused by: java.lang.IllegalStateException: Invalid extension 'cachesEndpointWebExtension': no endpoint found with type 'org.springframework.boot.actuate.cache.CachesEndpoint'
    at org.springframework.util.Assert.state(Assert.java:94)
    at org.springframework.boot.actuate.endpoint.annotation.EndpointDiscoverer.addExtensionBeans(EndpointDiscoverer.java:155)
    at org.springframework.boot.actuate.endpoint.annotation.EndpointDiscoverer.discoverEndpoints(EndpointDiscoverer.java:123)

Looks like the EndpointDiscoverer is trying to find a bean of type CachesEndpoint:

            EndpointBean endpointBean = byType.get(extensionBean.getEndpointType());

but the byType map contains MyCachesEndpoint.class instead of CachesEndpoint.class. So to overcome this I will have to register also a CachesEndpointWebExtension

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions