Resolve incompatibility between metrics-spring and springboot1.4

  springboot

abnormal

Caused by: java.lang.StackOverflowError
    at java.lang.reflect.Method.hashCode(Method.java:330) ~[?:1.8.0_65]
    at java.util.HashMap.hash(HashMap.java:338) ~[?:1.8.0_65]
    at java.util.HashMap.put(HashMap.java:611) ~[?:1.8.0_65]
    at java.util.HashSet.add(HashSet.java:219) ~[?:1.8.0_65]
    at org.springframework.core.annotation.AnnotatedElementUtils.searchWithFindSemantics(AnnotatedElementUtils.java:1119) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.core.annotation.AnnotatedElementUtils.searchWithFindSemantics(AnnotatedElementUtils.java:1183) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.core.annotation.AnnotatedElementUtils.searchWithFindSemantics(AnnotatedElementUtils.java:1208) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.core.annotation.AnnotatedElementUtils.searchWithFindSemantics(AnnotatedElementUtils.java:1086) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.core.annotation.AnnotatedElementUtils.searchWithFindSemantics(AnnotatedElementUtils.java:1060) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotationAttributes(AnnotatedElementUtils.java:656) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation(AnnotatedElementUtils.java:730) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:314) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e.getHealthCheckRegistry(<generated>) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.MetricsConfigurerComposite.getHealthCheckRegistry(MetricsConfigurerComposite.java:68) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration.getHealthCheckRegistry(DelegatingMetricsConfiguration.java:69) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e.CGLIB$getHealthCheckRegistry$3(<generated>) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e$$FastClassBySpringCGLIB$$7853f663.invoke(<generated>) ~[metrics-spring-3.1.3.jar:?]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e.getHealthCheckRegistry(<generated>) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.MetricsConfigurerComposite.getHealthCheckRegistry(MetricsConfigurerComposite.java:68) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration.getHealthCheckRegistry(DelegatingMetricsConfiguration.java:69) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e.CGLIB$getHealthCheckRegistry$3(<generated>) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e$$FastClassBySpringCGLIB$$7853f663.invoke(<generated>) ~[metrics-spring-3.1.3.jar:?]
    [... repeat 100 times ...]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e.getHealthCheckRegistry(<generated>) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.MetricsConfigurerComposite.getHealthCheckRegistry(MetricsConfigurerComposite.java:68) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration.getHealthCheckRegistry(DelegatingMetricsConfiguration.java:69) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e.CGLIB$getHealthCheckRegistry$3(<generated>) ~[metrics-spring-3.1.3.jar:?]
    at com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration$$EnhancerBySpringCGLIB$$2cc24d5e$$FastClassBySpringCGLIB$$7853f663.invoke(<generated>) ~[metrics-spring-3.1.3.jar:?]

Temporary plan

  • Remove @EnableMetrics

  • Add the following configuration

@Configuration
public class CustomDelegatingMetricsConfiguration extends DelegatingMetricsConfiguration {

    @Override
    @Autowired(required = false)
    public void setMetricsConfigurers(final List<MetricsConfigurer> configurers) {
    }
}

doc