Repository: camel Updated Branches: refs/heads/camel-2.12.x 6f3b86cf8 -> 103bae421 refs/heads/camel-2.13.x 2c1f12dc0 -> 40b308409
CAMEL-7576: Turn of online update checker for ehcache Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/40b30840 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/40b30840 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/40b30840 Branch: refs/heads/camel-2.13.x Commit: 40b308409ed21d480545dd8317fbbf8ce3ba3acd Parents: 2c1f12d Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Aug 26 15:47:52 2014 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Aug 26 15:48:25 2014 +0200 ---------------------------------------------------------------------- .../component/cache/CacheManagerFactory.java | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/40b30840/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheManagerFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheManagerFactory.java b/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheManagerFactory.java index f2476cb..1a69a7c 100755 --- a/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheManagerFactory.java +++ b/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheManagerFactory.java @@ -17,16 +17,35 @@ package org.apache.camel.component.cache; import net.sf.ehcache.CacheManager; +import net.sf.ehcache.config.Configuration; import org.apache.camel.support.ServiceSupport; +import org.apache.camel.util.ReflectionHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class CacheManagerFactory extends ServiceSupport { + private static final Logger LOG = LoggerFactory.getLogger(CacheManagerFactory.class); private CacheManager cacheManager; public synchronized CacheManager getInstance() { if (cacheManager == null) { cacheManager = createCacheManagerInstance(); + + // always turn off ET phone-home + LOG.debug("Turning off EHCache update checker ..."); + Configuration config = cacheManager.getConfiguration(); + try { + // need to set both the system property and bypass the setUpdateCheck method as that can be changed dynamically + System.setProperty("net.sf.ehcache.skipUpdateCheck", "true"); + ReflectionHelper.setField(config.getClass().getDeclaredField("updateCheck"), config, false); + + LOG.info("Turned off EHCache update checker. updateCheck={}", config.getUpdateCheck()); + } catch (Throwable e) { + // ignore + LOG.warn("Error turning off EHCache update checker. Beware information sent over the internet!", e); + } } - + return cacheManager; } @@ -48,6 +67,7 @@ public abstract class CacheManagerFactory extends ServiceSupport { // shutdown cache manager when stopping if (cacheManager != null) { cacheManager.shutdown(); + cacheManager = null; } } }