You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/08/26 15:50:44 UTC

[2/3] git commit: CAMEL-7576: Turn of online update checker for ehcache

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/64be7d20
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/64be7d20
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/64be7d20

Branch: refs/heads/master
Commit: 64be7d2089e6d0943fb949cf37562401b7c95aee
Parents: 85e35da
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 26 15:47:52 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 26 15:50:20 2014 +0200

----------------------------------------------------------------------
 .../component/cache/CacheManagerFactory.java    | 22 +++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/64be7d20/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;
         }
     }
 }