Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,32 +73,6 @@
@Conditional(LoadBalancerCacheAutoConfiguration.OnLoadBalancerCachingEnabledCondition.class)
public class LoadBalancerCacheAutoConfiguration {

@Configuration(proxyBeanMethods = false)
@Conditional(OnCaffeineCacheMissingCondition.class)
protected static class LoadBalancerCacheManagerWarnConfiguration {

@Bean
LoadBalancerCaffeineWarnLogger caffeineWarnLogger() {
return new LoadBalancerCaffeineWarnLogger();
}

}

static class LoadBalancerCaffeineWarnLogger implements InitializingBean {

private static final Log LOG = LogFactory.getLog(LoadBalancerCaffeineWarnLogger.class);

@Override
public void afterPropertiesSet() {
if (LOG.isWarnEnabled()) {
LOG.warn("Spring Cloud LoadBalancer is currently working with the default cache. "
+ "While this cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production."
+ "You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.");
}
}

}

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ Caffeine.class, CaffeineCacheManager.class })
protected static class CaffeineLoadBalancerCacheManagerConfiguration {
Expand All @@ -122,6 +96,11 @@ LoadBalancerCacheManager defaultLoadBalancerCacheManager(LoadBalancerCacheProper
return new DefaultLoadBalancerCacheManager(cacheProperties);
}

@Bean
LoadBalancerCaffeineWarnLogger caffeineWarnLogger() {
return new LoadBalancerCaffeineWarnLogger();
}

}

static final class OnCaffeineCacheMissingCondition extends AnyNestedCondition {
Expand Down Expand Up @@ -160,6 +139,21 @@ static class LoadBalancerCacheEnabled {

}

static class LoadBalancerCaffeineWarnLogger implements InitializingBean {

private static final Log LOG = LogFactory.getLog(LoadBalancerCaffeineWarnLogger.class);

@Override
public void afterPropertiesSet() {
if (LOG.isWarnEnabled()) {
LOG.warn("Spring Cloud LoadBalancer is currently working with the default cache. "
+ "While this cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production."
+ "You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.");
}
}

}

}

// Remove after adding hints to GraalVM reachability metadata repo
Expand Down
Loading