While trying to provide my own implementation of threaddump endpoint the application fails to start:
Found two endpoints with the id 'threaddump':...
I cannot extend existing ThreadDumpEndpoint because I want to change the @ReadOperation method public ThreadDumpDescriptor threadDump() that is used to produce json with my own String threadDump() method that produces text.
Because of this, the ThreadDumpEndpointAutoConfiguration @ConditionalOnMissingBean doesn't match my bean of different class, resulting in two endpoint beans.
It would be nice to allow overriding of actuator endpoint beans. For example using @Primary.
This way I can use standard endpoint instead of my custom endpoint.
Comment From: wilkinsona
I cannot extend existing ThreadDumpEndpoint because I want to change the
@ReadOperationmethodpublic ThreadDumpDescriptor threadDump()that is used to produce json with my ownString threadDump()method that produces text.
I don't think you need to do that. Instead, you can override the threadDump method without @ReadOperation:
@Bean
public ThreadDumpEndpoint threadDumpEndpoint() {
return new ThreadDumpEndpoint() {
@Override
public ThreadDumpDescriptor threadDump() {
return null;
}
};
}
This leaves the textThreadDump read operation in place and means that /actuator/threaddump will always produce a text/plain response.