log retry context

This commit is contained in:
spencergibb
2022-05-09 13:39:26 -04:00
parent a49a9d13d7
commit ed2f2cc20a
2 changed files with 8 additions and 1 deletions

View File

@@ -45,7 +45,12 @@ public class ConfigClientRetryBootstrapper implements BootstrapRegistryInitializ
RetryProperties properties = resource.getRetryProperties();
RetryTemplate retryTemplate = RetryTemplateFactory.create(properties, resource.getLog());
return retryTemplate.execute(
retryContext -> loadContext.getInvocation().apply(loadContext.getLoaderContext(), resource));
retryContext -> {
if (resource.getLog().isDebugEnabled()) {
resource.getLog().debug("Retry: count=" + retryContext.getRetryCount());
}
return loadContext.getInvocation().apply(loadContext.getLoaderContext(), resource);
});
}
return loadContext.getInvocation().apply(loadContext.getLoaderContext(), resource);
});

View File

@@ -45,6 +45,8 @@ public class ApplicationFailFastTests {
"--spring.cloud.config.enabled=true", "--spring.cloud.config.fail-fast=true",
"--spring.config.import=optional:configserver:http://serverhostdoesnotexist:1234",
"--spring.cloud.config.server.enabled=false",
"--logging.level.org.springframework.retry=TRACE",
"--logging.level.org.springframework.cloud.config=TRACE",
"--logging.level.org.springframework.boot.context.config=TRACE");
}).as("Exception not caused by fail fast").hasMessageContaining("fail fast");
assertThat(output).contains("Retry: count=5");