From 781a26b56d967a72f3fd13f73bc8be8520b22cf4 Mon Sep 17 00:00:00 2001 From: "Mark H. Wood" Date: Mon, 29 Jan 2018 14:29:42 -0500 Subject: [PATCH] [DS-3694] Configure CacheManagers to suppress version check. Don't set corresponding system property -- it's the wrong way to do this in Servlet code, and anyway the manager is already initialized before we can set it. Remove fallback code that should never execute because injection is @Required. --- .../services/caching/CachingServiceImpl.java | 30 +------------------ .../main/resources/caching/ehcache-config.xml | 4 ++- dspace/config/hibernate-ehcache-config.xml | 4 ++- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/dspace-services/src/main/java/org/dspace/services/caching/CachingServiceImpl.java b/dspace-services/src/main/java/org/dspace/services/caching/CachingServiceImpl.java index 787f9ded93..63cdf32181 100644 --- a/dspace-services/src/main/java/org/dspace/services/caching/CachingServiceImpl.java +++ b/dspace-services/src/main/java/org/dspace/services/caching/CachingServiceImpl.java @@ -7,8 +7,6 @@ */ package org.dspace.services.caching; -import java.io.IOException; -import java.io.InputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -19,7 +17,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import net.sf.ehcache.CacheManager; import net.sf.ehcache.Ehcache; import net.sf.ehcache.Statistics; import org.dspace.kernel.ServiceManager; @@ -236,37 +233,12 @@ public final class CachingServiceImpl /* (non-Javadoc) * @see org.dspace.kernel.mixins.InitializedService#init() */ + @Override public void init() { log.info("init()"); // get settings reloadConfig(); - // don't display the EhCache update notice in logs - it's meant for developers, not users - System.setProperty("net.sf.ehcache.skipUpdateCheck", "true"); - - // make sure we have a cache manager - if (cacheManager == null) { - // not injected so we need to create one - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - InputStream is = cl.getResourceAsStream(DEFAULT_CONFIG); - try { - if (is == null) { - throw new IllegalStateException( - "Could not init the cache manager, no config file found as a resource in the classloader: " + - DEFAULT_CONFIG); - } - cacheManager = new CacheManager(is); - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException e) { - log.debug("Error closing config stream", e); - } - } - } - } - // get all caches out of the cachemanager and load them into the cache list List ehcaches = getAllEhCaches(false); for (Ehcache ehcache : ehcaches) { diff --git a/dspace-services/src/main/resources/caching/ehcache-config.xml b/dspace-services/src/main/resources/caching/ehcache-config.xml index f915e105fd..7199fc9340 100644 --- a/dspace-services/src/main/resources/caching/ehcache-config.xml +++ b/dspace-services/src/main/resources/caching/ehcache-config.xml @@ -8,7 +8,9 @@ http://www.dspace.org/license/ --> - + - +