@@ -0,0 +1,2301 @@
+package io.micrometer.spring.async;%0A%0Aimport io.micrometer.core.Issue;%0Aimport io.micrometer.core.instrument.MeterRegistry;%0Aimport io.micrometer.core.instrument.Metrics;%0Aimport io.micrometer.spring.autoconfigure.MeterRegistryPostProcessor;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.autoconfigure.SpringBootApplication;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.context.ApplicationContext;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.context.annotation.Import;%0Aimport org.springframework.core.task.AsyncTaskExecutor;%0Aimport org.springframework.scheduling.annotation.AsyncConfigurerSupport;%0Aimport org.springframework.scheduling.annotation.EnableAsync;%0Aimport org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport static java.util.Collections.emptyList;%0A%0A@RunWith(SpringRunner.class)%0A@SpringBootTest(classes = ThreadPoolTaskExecutorMetricsIntegrationTest.App.class)%0Apublic class ThreadPoolTaskExecutorMetricsIntegrationTest %7B%0A%0A    @Autowired%0A    MeterRegistry registry;%0A%0A    @Issue(%22#459%22)%0A    @Test%0A    public void executorMetricsPhase() %7B%0A        registry.get(%22jvm.memory.max%22).gauge();%0A    %7D%0A%0A    @SpringBootApplication(scanBasePackages = %22ignore%22)%0A    @Import(AsyncExecutorConfig.class)%0A    static class App %7B%0A        @Bean%0A        public AsyncTaskExecutor executor(MeterRegistry registry) %7B%0A            return new TimedThreadPoolTaskExecutor(registry, %22threads%22, emptyList());%0A        %7D%0A    %7D%0A%0A    /**%0A     * Injecting the registry instead would cause early evaluation of the registry and the registry%0A     * wouldn't be discovered by %7B@link MeterRegistryPostProcessor%7D.%0A     */%0A    @Configuration%0A    @EnableAsync%0A    static class AsyncExecutorConfig extends AsyncConfigurerSupport %7B%0A        @Bean%0A        public AsyncTaskExecutor getAsyncExecutor() %7B%0A            final ThreadPoolTaskExecutor executor = new TimedThreadPoolTaskExecutor(Metrics.globalRegistry, %22workers%22, emptyList());%0A            executor.initialize();%0A            return executor;%0A        %7D%0A    %7D%0A%7D%0A

Test proving how to register TimedThreadPoolTaskExecutor without eagerly instantiating MeterRegistry (fixes #459)